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,34 @@
/**
* Copyright (C) 2016-2017 DSpot Sp. z o.o
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.datedialog;

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

import org.androidannotations.annotations.EBean;

import java.util.Locale;

@EBean
public class ModelBean {
public void selectDate() {
$DateDialog()
.title("Select Date")
.message("Select Date of the Job");

int $year = 0, $month = 0, $day = 0;
String selectedDate = String.format(Locale.US, "Selected date is %02d-%02d-%02d", $year , $month+1, $day);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.dspot.declex.test.dialog.datedialog;

import com.dspot.declex.actions.DateDialogActionHolder;
import com.dspot.declex.actions.DateDialogActionHolder_;

import org.junit.Before;
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.Calendar;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

@RunWith(RobolectricTestRunner.class)
@Config(
manifest = "app/src/main/AndroidManifest.xml",
sdk = 25
)
@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*", "org.powermock.*" })
@PrepareForTest({ModelBean_.class, DateDialogActionHolder_.class})
public class TestDateDialog {

@Rule
public PowerMockRule rule = new PowerMockRule();

@Before
public void setUp() throws Exception {

}

@Test
public void testDateDialogAction() {
DateDialogActionHolder_ actionDateDialog = DateDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionDateDialog.init();
assertNotNull(actionDateDialog);
assertNotNull(actionDateDialog.dialog());

actionDateDialog.init(2017, 11, 18);
assertNotNull(actionDateDialog.dialog());

actionDateDialog.init(Calendar.getInstance());
assertNotNull(actionDateDialog.dialog());
}

@Test
public void testDateDialogActionProperties() {
DateDialogActionHolder_ actionDateDialog = DateDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionDateDialog.init();
assertNotNull(actionDateDialog);
assertNotNull(actionDateDialog.title("Select Date"));
assertNotNull(actionDateDialog.message("Select Date of the Job"));
}

@Test
public void testDateDialogSelectAction() {
DateDialogActionHolder.DateSetRunnable dateSelected = new DateDialogActionHolder.DateSetRunnable() {
@Override
public void run() {

}
};

DateDialogActionHolder_ actionDateDialog = DateDialogActionHolder_.getInstance_(RuntimeEnvironment.application);
actionDateDialog.init();
actionDateDialog.build(dateSelected, null, null);
actionDateDialog.execute();

assertNotNull(actionDateDialog);
assertNotNull(actionDateDialog.dialog());
}
}