Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (C) 2016-2017 DSpot Sp. z o.o
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dspot.declex.test.dialog.progressdialog;

import android.app.Dialog;

import com.dspot.declex.test.R;

import static com.dspot.declex.actions.Action.*;

import org.androidannotations.annotations.EBean;

@EBean
public class ModelBean {
public void downloadUsers() {
Dialog dialog = $ProgressDialog()
.title("Testing")
.message("DecleX Test Now")
.dialog();
dialog.dismiss();
}

public void downloadUsersUsingResources() {
Dialog dialog = $ProgressDialog()
.title(R.string.title)
.message(R.string.message)
.dialog();
dialog.dismiss();
}

public void downloadUsersWithActions(Runnable dismissed, Runnable shown) {
Dialog dialog = $ProgressDialog()
.title("Testing")
.message("DecleX Test Now")
.dialog();

if($ProgressDialog.Shown) {
if(shown != null) shown.run();
}

if($ProgressDialog.Dismissed) {
if(dismissed != null) dismissed.run();
}

dialog.dismiss();
}

public void showInformation(String information) {
$ProgressDialog().message("Upload information: {information} to the server");
}
}
2 changes: 2 additions & 0 deletions declex-test/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<resources>
<string name="app_name">DecleX Test</string>
<string name="title">Testing</string>
<string name="message">DecleX Test Now</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.dspot.declex.test.dialog.progressdialog;

import com.dspot.declex.actions.ProgressDialogActionHolder_;
import com.dspot.declex.test.R;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.Assert.*;

@RunWith(RobolectricTestRunner.class)
@Config(
manifest = "app/src/main/AndroidManifest.xml",
sdk = 25
)
@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*", "org.powermock.*"})
@PrepareForTest({ModelBean_.class, ProgressDialogActionHolder_.class})
public class TestProgressDialog {
@Rule
public PowerMockRule rule = new PowerMockRule();

@Test
public void testProgressDialogAction() {
ProgressDialogActionHolder_ actionProgress = ProgressDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionProgress.init();
assertNotNull(actionProgress);
assertNotNull(actionProgress.dialog());
}

@Test
public void testProgressDialogActionProperties() {
ProgressDialogActionHolder_ actionProgress = ProgressDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionProgress.init();
assertNotNull(actionProgress);
assertNotNull(actionProgress.title("Testing"));
assertNotNull(actionProgress.message("DecleX Test Now"));
}

@Test
public void testProgressDialogActionResources() {
ProgressDialogActionHolder_ actionProgress = ProgressDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionProgress.init();
assertNotNull(actionProgress);
assertNotNull(actionProgress.title(R.string.title));
assertNotNull(actionProgress.message(R.string.message));

String information = "Data User Thomas";
assertNotNull(actionProgress.message(((("Upload information: " + ((information) + "")) + " to the server"))));
}

@Test
public void testProgressDialogActionEvents() {
Runnable shownAction = new Runnable() {
@Override
public void run() {

}
};

Runnable dismissedAction = new Runnable() {
@Override
public void run() {

}
};

ProgressDialogActionHolder_ actionProgress = ProgressDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionProgress.init();
actionProgress.build(shownAction, null, dismissedAction);
actionProgress.execute();

assertNotNull(actionProgress);
assertNotNull(actionProgress.dialog());
assertNotNull(actionProgress.title("Testing"));
assertNotNull(actionProgress.message("DecleX Test Now"));
}
}