Skip to content

Test commit #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
androidTestCompile 'com.android.support:support-annotations:+'
compile 'com.android.support:appcompat-v7:23.0.1'
androidTestCompile 'com.android.support:support-annotations:23.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}
46 changes: 20 additions & 26 deletions app/src/androidTest/java/gettipsi/com/project1/DropdownTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import android.app.KeyguardManager;
import android.content.Context;
import android.os.SystemClock;
import android.support.test.espresso.assertion.ViewAssertions;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.WindowManager;

import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -47,20 +45,16 @@ public class DropdownTests {

@Before
public void initValidData() {
final MainActivity activity = activityRule.getActivity();
activity.runOnUiThread(new Runnable() {
activityRule.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
KeyguardManager mKG = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock mLock = mKG.newKeyguardLock("keyguard");
mLock.disableKeyguard();

//turn the screen on
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
try {
KeyguardManager mKeyGuardManager = (KeyguardManager) activityRule.getActivity().getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock mLock = mKeyGuardManager.newKeyguardLock(Context.KEYGUARD_SERVICE);
mLock.disableKeyguard();
} catch (Exception e) {
e.printStackTrace();
}
}
});
items = Arrays.<Object>asList("One", "Two", "Three", "Four");
Expand All @@ -82,22 +76,22 @@ public void checkItemsSelection() {
.perform(new SetSelectedAction(0))
.check(matches(withSpinnerText(items.get(0).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SetSelectedAction(1))
.check(matches(withSpinnerText(items.get(1).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SetSelectedAction(2))
.check(matches(withSpinnerText(items.get(2).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SetSelectedAction(3))
.check(matches(withSpinnerText(items.get(3).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);

}

Expand All @@ -108,45 +102,45 @@ public void checkItemsWithNameSelection() {
.perform(new SelectElementWithNameAction(items.get(0).toString()))
.check(matches(withSpinnerText(items.get(0).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SelectElementWithNameAction(items.get(1).toString()))
.check(matches(withSpinnerText(items.get(1).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SelectElementWithNameAction(items.get(2).toString()))
.check(matches(withSpinnerText(items.get(2).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
onView(withId(R.id.dropdownId))
.perform(new SelectElementWithNameAction(items.get(3).toString()))
.check(matches(withSpinnerText(items.get(3).toString())));

SystemClock.sleep(1000);
// SystemClock.sleep(1000);
}

@Test
public void checkItemsClickSelection() {
setupItems();
String item = items.get(0).toString();
onView(withId(R.id.dropdownId)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(item))).perform(click());
onData(allOf(is(instanceOf(String.class)))).atPosition(0).perform(click());
onView(withId(R.id.dropdownId)).check(matches(withSpinnerText(containsString(item))));

String item1 = items.get(1).toString();
onView(withId(R.id.dropdownId)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(item1))).perform(click());
onData(allOf(is(instanceOf(String.class)))).atPosition(1).perform(click());
onView(withId(R.id.dropdownId)).check(matches(withSpinnerText(containsString(item1))));

String item2 = items.get(2).toString();
onView(withId(R.id.dropdownId)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(item2))).perform(click());
onData(allOf(is(instanceOf(String.class)))).atPosition(2).perform(click());
onView(withId(R.id.dropdownId)).check(matches(withSpinnerText(containsString(item2))));

String item3 = items.get(3).toString();
onView(withId(R.id.dropdownId)).perform(click());
onData(allOf(is(instanceOf(String.class)), is(item3))).perform(click());
onData(allOf(is(instanceOf(String.class)))).atPosition(3).perform(click());
onView(withId(R.id.dropdownId)).check(matches(withSpinnerText(containsString(item3))));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gettipsi.com.project1.action;

import android.support.test.espresso.UiController;
import android.support.test.espresso.ViewAction;
import android.view.View;

import org.hamcrest.Matcher;

public class UnlockKeyguardAction implements ViewAction {

@Override
public Matcher<View> getConstraints() {
return null;
}

@Override
public String getDescription() {
return null;
}

@Override
public void perform(UiController uiController, View view) {

}
}
31 changes: 31 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
general:
artifacts:
- /home/ubuntu/Project1/app/build/outputs/apk/

machine:
environment:
ANDROID_HOME: /usr/local/android-sdk-linux

dependencies:
override:
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-24.0.2,android-24,sys-img-armeabi-v7a-android-24,extra-google-m2repository,extra-google-google_play_services,extra-android-support
- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

test:
override:
- (./gradlew assemble):
timeout: 360

test:
override:
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
- circle-android wait-for-boot
- sleep 30
- adb shell input keyevent 82
- ./gradlew connectedAndroidTest -PdisablePreDex
- test ! -d app/build/outputs || cp -r app/build/outputs $CIRCLE_ARTIFACTS
- test ! -d app/build/reports || cp -r app/build/reports $CIRCLE_TEST_REPORTS
# - cp -r /home/ubuntu/Project1/app/build/outputs $CIRCLE_ARTIFACTS
# - cp -r /home/ubuntu/Project1/app/build/outputs/androidTest-results