Compare commits
8 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
603d296f5b | |
|
|
91f07b9a61 | |
|
|
8a85e5b27a | |
|
|
e86ebcf969 | |
|
|
bd08039fd1 | |
|
|
f460571e7c | |
|
|
ce61dbb65b | |
|
|
ad6d494f14 |
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Install package and grant all permissions
|
||||||
|
adb install -r -g sample/build/outputs/apk/sample-debug.apk
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Build
|
||||||
|
|
||||||
|
./gradlew clean build check
|
||||||
15
.travis.yml
15
.travis.yml
|
|
@ -20,8 +20,17 @@ cache:
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- chmod +x gradlew
|
- chmod +x gradlew
|
||||||
# - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
|
|
||||||
# - emulator -avd test -no-skin -no-audio -no-window &
|
#before_script:
|
||||||
|
# # Make sure emulator has started before running tests
|
||||||
|
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
|
||||||
|
- emulator -avd test -no-skin -no-audio -no-window &
|
||||||
|
- android-wait-for-emulator
|
||||||
|
- adb shell input keyevent 82 &
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- ./gradlew clean build check
|
- ./gradlew clean build connectedCheck
|
||||||
|
# connectedCheck
|
||||||
|
# - ./gradlew assembleDebug
|
||||||
|
# - ./gradlew connectedAndroidTestDebug --info
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ android {
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode Integer.parseInt(project.VERSION_CODE)
|
versionCode Integer.parseInt(project.VERSION_CODE)
|
||||||
versionName project.VERSION_NAME
|
versionName project.VERSION_NAME
|
||||||
|
|
||||||
|
//testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
|
||||||
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
@ -37,6 +40,11 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Conflict in test project
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'LICENSE.txt'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -45,4 +53,16 @@ dependencies {
|
||||||
|
|
||||||
// Image loading sample
|
// Image loading sample
|
||||||
compile 'com.github.bumptech.glide:glide:3.5.2'
|
compile 'com.github.bumptech.glide:glide:3.5.2'
|
||||||
|
|
||||||
|
// For running tests
|
||||||
|
androidTestCompile ('com.android.support.test:runner:0.3') {
|
||||||
|
exclude module: 'support-annotations'
|
||||||
|
}
|
||||||
|
androidTestCompile ('com.android.support.test:rules:0.3') {
|
||||||
|
exclude module: 'support-annotations'
|
||||||
|
}
|
||||||
|
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2') {
|
||||||
|
exclude module: 'support-annotations'
|
||||||
|
}
|
||||||
|
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2015 Jonas Kalderstam
|
||||||
|
~
|
||||||
|
~ This program is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 3 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ This program is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU Lesser General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU Lesser General Public License
|
||||||
|
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<manifest
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="com.nononsenseapps.filepicker.sample">
|
||||||
|
|
||||||
|
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
|
||||||
|
</manifest>
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Jonas Kalderstam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nononsenseapps.filepicker.sample;
|
||||||
|
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.test.InstrumentationRegistry;
|
||||||
|
import android.support.test.espresso.action.ViewActions;
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.test.ViewAsserts;
|
||||||
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static android.support.test.espresso.Espresso.onView;
|
||||||
|
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
|
public class NoNonsenseFilePickerTest extends ActivityInstrumentationTestCase2<NoNonsenseFilePicker> {
|
||||||
|
|
||||||
|
private NoNonsenseFilePicker mActivity;
|
||||||
|
private View mStartButton;
|
||||||
|
private static final String[] sTestFiles = new String[] {"zz.testfile1.zxvf", "zz.testfile2.zxvf"};
|
||||||
|
|
||||||
|
public NoNonsenseFilePickerTest() {
|
||||||
|
super(NoNonsenseFilePicker.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
|
||||||
|
|
||||||
|
setActivityInitialTouchMode(true);
|
||||||
|
|
||||||
|
mActivity = getActivity();
|
||||||
|
mStartButton = mActivity.findViewById(R.id.button_sd);
|
||||||
|
|
||||||
|
// Create a few files so we know something exists
|
||||||
|
createTestFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTestFiles() throws IOException {
|
||||||
|
String folder = Environment.getExternalStorageDirectory().getPath();
|
||||||
|
for (String filename: sTestFiles) {
|
||||||
|
File file = new File(folder + "/" + filename);
|
||||||
|
if (!file.exists()) {
|
||||||
|
assertTrue(file.createNewFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load app, and make sure it loaded
|
||||||
|
*/
|
||||||
|
@MediumTest
|
||||||
|
public void testStart() {
|
||||||
|
final View mainView = mActivity.findViewById(R.id.scrollView);
|
||||||
|
assertNotNull(mainView);
|
||||||
|
|
||||||
|
final View radioButtons = mActivity.findViewById(R.id.radioGroup);
|
||||||
|
assertNotNull(radioButtons);
|
||||||
|
|
||||||
|
ViewAsserts.assertOnScreen(mainView, radioButtons);
|
||||||
|
|
||||||
|
ViewAsserts.assertOnScreen(mainView, mStartButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start picker with default options
|
||||||
|
*/
|
||||||
|
@MediumTest
|
||||||
|
public void testNoSelectionOnOk() {
|
||||||
|
getActivity();
|
||||||
|
onView(withId(R.id.button_sd)).perform(ViewActions.click());
|
||||||
|
|
||||||
|
// Activity should now be started
|
||||||
|
// Verify that OK-button is present
|
||||||
|
//onView(withId(R.id.nnf_button_ok)).check(ViewAssertions.matches(withText(android.R.string.ok)));
|
||||||
|
// Press it
|
||||||
|
onView(withId(R.id.nnf_button_ok)).perform(ViewActions.click());
|
||||||
|
|
||||||
|
// Should have given a toast, asking to select something first
|
||||||
|
// Press cancel to go back
|
||||||
|
onView(withId(R.id.nnf_button_cancel)).perform(ViewActions.click());
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectOne() {
|
||||||
|
getActivity();
|
||||||
|
onView(withId(R.id.button_sd)).perform(ViewActions.click());
|
||||||
|
|
||||||
|
// Select a file
|
||||||
|
|
||||||
|
// Activity should now be started
|
||||||
|
// Verify that OK-button is present
|
||||||
|
//onView(withId(R.id.nnf_button_ok)).check(ViewAssertions.matches(withText(android.R.string.ok)));
|
||||||
|
// Press it
|
||||||
|
onView(withId(R.id.nnf_button_ok)).perform(ViewActions.click());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 Jonas Kalderstam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nononsenseapps.filepicker.sample;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.test.uiautomator.UiObject;
|
||||||
|
import android.support.test.uiautomator.UiScrollable;
|
||||||
|
import android.support.test.uiautomator.UiSelector;
|
||||||
|
import android.support.test.uiautomator.Until;
|
||||||
|
import android.test.InstrumentationTestCase;
|
||||||
|
import android.support.test.uiautomator.UiDevice;
|
||||||
|
import android.support.test.uiautomator.By;
|
||||||
|
import android.test.suitebuilder.annotation.MediumTest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class UITest extends InstrumentationTestCase {
|
||||||
|
|
||||||
|
public static final String PKG_SAMPLE = "com.nononsenseapps.filepicker.sample";
|
||||||
|
private static final long TIMEOUT = 10;
|
||||||
|
private UiDevice mDevice;
|
||||||
|
|
||||||
|
|
||||||
|
private static final String[] sTestFiles = new String[] {"zz.testfile1.zxvf", "zz.testfile2.zxvf"};
|
||||||
|
|
||||||
|
public void setUp() throws IOException {
|
||||||
|
// Initialize UiDevice instance
|
||||||
|
mDevice = UiDevice.getInstance(getInstrumentation());
|
||||||
|
// Launch sample app
|
||||||
|
Context context = getInstrumentation().getContext();
|
||||||
|
Intent intent = context.getPackageManager()
|
||||||
|
.getLaunchIntentForPackage(PKG_SAMPLE);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
// Clear out any previous instances
|
||||||
|
context.startActivity(intent);
|
||||||
|
mDevice.wait(Until.hasObject(By.pkg(PKG_SAMPLE).depth(0)), TIMEOUT);
|
||||||
|
|
||||||
|
// Create a few files so we know something exists
|
||||||
|
createTestFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTestFiles() throws IOException {
|
||||||
|
String folder = Environment.getExternalStorageDirectory().getPath();
|
||||||
|
for (String filename: sTestFiles) {
|
||||||
|
File file = new File(folder + "/" + filename);
|
||||||
|
if (!file.exists()) {
|
||||||
|
assertTrue(file.createNewFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectSingleFile() throws Exception {
|
||||||
|
// Default options are correct, press start
|
||||||
|
UiObject sdButton = mDevice.findObject(new UiSelector().resourceId("com.nononsenseapps.filepicker.sample:id/button_sd"));
|
||||||
|
|
||||||
|
assertTrue(sdButton.exists());
|
||||||
|
|
||||||
|
sdButton.click();
|
||||||
|
|
||||||
|
// Scroll to bottom and click on a test file
|
||||||
|
|
||||||
|
UiScrollable list = new UiScrollable(new UiSelector()
|
||||||
|
.className("android.support.v7.widget.RecyclerView"));
|
||||||
|
UiObject testFileItem2 = list.getChildByText(new UiSelector()
|
||||||
|
.resourceId("com.nononsenseapps.filepicker.sample:id/nnf_item_container"),
|
||||||
|
sTestFiles[1]);
|
||||||
|
testFileItem2.click();
|
||||||
|
|
||||||
|
// Click another one, only one should be returned
|
||||||
|
UiObject testFileItem1 = list.getChildByText(new UiSelector()
|
||||||
|
.resourceId("com.nononsenseapps.filepicker.sample:id/nnf_item_container"),
|
||||||
|
sTestFiles[0]);
|
||||||
|
testFileItem1.click();
|
||||||
|
|
||||||
|
// Press oK
|
||||||
|
UiObject okButton = mDevice.findObject(new UiSelector().resourceId("com.nononsenseapps.filepicker.sample:id/nnf_button_ok"));
|
||||||
|
okButton.click();
|
||||||
|
|
||||||
|
// Make sure result is displayed correctly
|
||||||
|
UiObject resultField = mDevice.findObject(new UiSelector().textContains(sTestFiles[0]));
|
||||||
|
assertTrue(resultField.exists());
|
||||||
|
|
||||||
|
resultField = mDevice.findObject(new UiSelector().textContains(sTestFiles[1]));
|
||||||
|
assertFalse(resultField.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectMultipleFiles() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectSingleDir() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectMultipleDirs() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testSelectMultipleAny() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testCreateDirModeFile() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testCreateDirModeDir() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
@MediumTest
|
||||||
|
public void testCreateDirModeAny() throws Exception {
|
||||||
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue