зеркало из https://github.com/nextcloud/android.git
Add support for integration tests
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
Родитель
aac3f6a21a
Коммит
76d3747748
|
@ -0,0 +1,13 @@
|
|||
codecov:
|
||||
branch: master
|
||||
ci:
|
||||
- drone.nextcloud.com
|
||||
|
||||
coverage:
|
||||
precision: 2
|
||||
round: down
|
||||
range: "70...100"
|
||||
|
||||
comment:
|
||||
layout: "header, diff, changes, uncovered, tree"
|
||||
behavior: default
|
62
.drone.yml
62
.drone.yml
|
@ -1,35 +1,34 @@
|
|||
pipeline:
|
||||
test:
|
||||
compile:
|
||||
image: nextcloudci/android:android-35
|
||||
commands:
|
||||
# uncomment gplay for Gplay, Modified only
|
||||
- sh -c "if [ '$FLAVOUR' != 'Generic' ]; then sed -i '/.*com.google.*/s/^.*\\/\\///g' build.gradle; fi"
|
||||
# uncomment gplay for Gplay
|
||||
- sh -c "if [ '${FLAVOR}' = 'Gplay' ]; then sed -i '/.*com.google.*/s/^.*\\/\\///g' build.gradle; fi"
|
||||
# build app and assemble APK
|
||||
- sh -c "if [ '${FLAVOR}' != 'Lint' ]; then ./gradlew assemble${FLAVOR}; fi"
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: [Generic, Gplay]
|
||||
|
||||
# - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 20M
|
||||
# - emulator -avd test -no-window &
|
||||
# - ./wait_for_emulator.sh
|
||||
|
||||
# build app and assemble APK, in debug mode
|
||||
- sh -c "if [ '$FLAVOUR' != 'Lint' ]; then ./gradlew assemble${FLAVOUR}; fi"
|
||||
|
||||
# run all the instrumented tests of app module - DISABLED until we get an stable setup for Espresso in Travis
|
||||
# - ./gradlew connectedDebugAndroidTest --info
|
||||
|
||||
# install app, then assemble and install instrumented tests of app module
|
||||
# - ./gradlew :install${FLAVOUR}Debug
|
||||
# - ./gradlew :install${FLAVOUR}DebugAndroidTest
|
||||
|
||||
# run sample instrumented unit test
|
||||
# TODO fails because test runner is not available
|
||||
#- adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner
|
||||
|
||||
environment:
|
||||
- ANDROID_TARGET=android-32
|
||||
- ANDROID_ABI=armeabi-v7a
|
||||
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:/opt/android-sdk-linux/tools/lib64/gles_mesa/
|
||||
test:
|
||||
image: nextcloudci/android:android-35
|
||||
privileged: true
|
||||
commands:
|
||||
- emulator -avd android-27 -no-window -no-audio &
|
||||
- ./wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "Unit"
|
||||
- ./gradlew assembleGplayDebug installGplayDebugAndroidTest
|
||||
- ./gradlew createGplayDebugCoverageReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "IT"
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
secrets: [ LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
|
||||
lint:
|
||||
image: nextcloudci/android:android-32
|
||||
image: nextcloudci/android:android-35
|
||||
commands:
|
||||
# needs gplay
|
||||
- sed -i '/.*com.google.*/s/^.*\\/\\///g' build.gradle
|
||||
|
@ -38,7 +37,7 @@ pipeline:
|
|||
secrets: [ GIT_USERNAME, GIT_TOKEN, LOG_USERNAME, LOG_PASSWORD ]
|
||||
when:
|
||||
matrix:
|
||||
FLAVOUR: Lint
|
||||
FLAVOR: Lint
|
||||
|
||||
notify:
|
||||
image: drillster/drone-email
|
||||
|
@ -56,9 +55,16 @@ pipeline:
|
|||
branch: master
|
||||
|
||||
matrix:
|
||||
FLAVOUR:
|
||||
FLAVOR:
|
||||
- Generic
|
||||
- Gplay
|
||||
- Lint
|
||||
|
||||
services:
|
||||
server:
|
||||
image: nextcloudci/server:server-1
|
||||
when:
|
||||
matrix:
|
||||
FLAVOR: Gplay
|
||||
|
||||
branches: master
|
||||
|
|
38
build.gradle
38
build.gradle
|
@ -16,6 +16,10 @@ buildscript {
|
|||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
classpath 'org.codehaus.groovy:groovy-all:2.4.12'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +27,7 @@ apply plugin: 'com.android.application'
|
|||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'findbugs'
|
||||
apply plugin: 'jacoco-android'
|
||||
|
||||
configurations.all {
|
||||
// check for updates every build
|
||||
|
@ -33,6 +38,7 @@ ext {
|
|||
supportLibraryVersion = '27.1.1'
|
||||
googleLibraryVersion = '12.0.1'
|
||||
androidLibraryVersion = '1.0.40'
|
||||
jacocoVersion = "0.7.4.201502262128"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
|
@ -99,6 +105,12 @@ android {
|
|||
|
||||
flavorDimensions "default"
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
generic {
|
||||
|
@ -251,6 +263,14 @@ dependencies {
|
|||
implementation 'org.jetbrains:annotations:15.0'
|
||||
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.0.0'
|
||||
|
||||
// jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
|
||||
// jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
// androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.core:${jacocoVersion}"
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.report:${jacocoVersion}"
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
|
@ -270,5 +290,23 @@ android.applicationVariants.all { variant ->
|
|||
}
|
||||
}
|
||||
|
||||
task combinedTestReport(type: JacocoReport) {
|
||||
|
||||
reports {
|
||||
xml.enabled = true
|
||||
html.enabled = true
|
||||
}
|
||||
|
||||
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
|
||||
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
|
||||
def mainSrc = "$project.projectDir/src/main/java"
|
||||
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
// uncomment for gplay (must be at the bottom)
|
||||
//apply plugin: 'com.google.gms.google-services'
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/integrationTests
|
||||
ID=$3
|
||||
USER=$1
|
||||
PASS=$2
|
||||
TYPE=$4
|
||||
|
||||
if [ $TYPE = "IT" ]; then
|
||||
cd build/reports/androidTests/connected/flavors/GPLAY
|
||||
else
|
||||
cd build/reports/tests/testGplayDebugUnitTest
|
||||
fi
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$ID/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$ID/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
|
||||
echo "Uploaded failing tests to https://nextcloud.kaminsky.me/index.php/s/XqY52jBr9ZYfDiz -> $ID"
|
||||
exit 1
|
|
@ -0,0 +1,90 @@
|
|||
package com.owncloud.android;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Common base for all integration tests
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
protected static Account account;
|
||||
protected static Context context;
|
||||
|
||||
private static final String username = "test";
|
||||
private static final String password = "test";
|
||||
private static final String baseUrl = "server";
|
||||
|
||||
public AbstractIT() {
|
||||
super(MainApp.class);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
context = MainApp.getAppContext();
|
||||
|
||||
Account temp = new Account(username + "@" + baseUrl, MainApp.getAccountType());
|
||||
|
||||
if (!com.owncloud.android.authentication.AccountUtils.exists(temp, context)) {
|
||||
AccountManager accountManager = AccountManager.get(context);
|
||||
accountManager.addAccountExplicitly(temp, password, null);
|
||||
accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(com.owncloud.android.authentication.AccountUtils.ACCOUNT_VERSION));
|
||||
accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "http://" + baseUrl);
|
||||
}
|
||||
|
||||
account = com.owncloud.android.authentication.AccountUtils.getOwnCloudAccountByName(context,
|
||||
username + "@" + baseUrl);
|
||||
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, context);
|
||||
|
||||
createDummyFiles();
|
||||
} catch (OperationCanceledException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticatorException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected FileDataStorageManager getStorageManager() {
|
||||
return new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
|
||||
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + "/123.txt");
|
||||
file.createNewFile();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.owncloud.android;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests related to file operations
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FileIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void testCreateFolder() {
|
||||
String path = "/testFolder/";
|
||||
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, true);
|
||||
RemoteOperationResult result = syncOp.execute(client, getStorageManager());
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// folder exists
|
||||
assertTrue(getStorageManager().getFileByPath(path).isFolder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateNonExistingSubFolder() {
|
||||
String path = "/testFolder/1/2/3/4/5/";
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, true);
|
||||
RemoteOperationResult result = syncOp.execute(client, getStorageManager());
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// folder exists
|
||||
assertTrue(getStorageManager().getFileByPath(path).isFolder());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.owncloud.android;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* Tests related to file uploads
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class UploadIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void testSimpleUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
"/testUpload/1.txt", account.name);
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
});
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadInNonExistingFolder() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
"/testUpload/2/3/4/1.txt", account.name);
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
});
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
}
|
|
@ -1,136 +1,136 @@
|
|||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.authentication;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class AuthenticatorActivityTest {
|
||||
|
||||
public static final String EXTRA_ACTION = "ACTION";
|
||||
public static final String EXTRA_ACCOUNT = "ACCOUNT";
|
||||
|
||||
private static final int WAIT_LOGIN = 5000;
|
||||
|
||||
private static final String ERROR_MESSAGE = "Activity not finished";
|
||||
private static final String RESULT_CODE = "mResultCode";
|
||||
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<AuthenticatorActivity> mActivityRule = new ActivityTestRule<AuthenticatorActivity>(
|
||||
AuthenticatorActivity.class){
|
||||
@Override
|
||||
protected Intent getActivityIntent() {
|
||||
|
||||
Context targetContext = InstrumentationRegistry.getInstrumentation()
|
||||
.getTargetContext();
|
||||
Intent result = new Intent(targetContext, AuthenticatorActivity.class);
|
||||
result.putExtra(EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
|
||||
result.putExtra(EXTRA_ACCOUNT, "");
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@Before
|
||||
public void init(){
|
||||
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
||||
/*Point[] coordinates = new Point[4];
|
||||
coordinates[0] = new Point(248, 1020);
|
||||
coordinates[1] = new Point(248, 429);
|
||||
coordinates[2] = new Point(796, 1020);
|
||||
coordinates[3] = new Point(796, 429);*/
|
||||
try {
|
||||
if (!uiDevice.isScreenOn()) {
|
||||
uiDevice.wakeUp();
|
||||
//uiDevice.swipe(coordinates, 10);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkLogin()
|
||||
throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
Bundle arguments = InstrumentationRegistry.getArguments();
|
||||
|
||||
// Get values passed
|
||||
String testUser = arguments.getString("TEST_USER");
|
||||
String testPassword = arguments.getString("TEST_PASSWORD");
|
||||
String testServerURL = arguments.getString("TEST_SERVER_URL");
|
||||
|
||||
// Check that login button is disabled
|
||||
onView(withId(R.id.buttonOK))
|
||||
.check(matches(not(isEnabled())));
|
||||
|
||||
// Type server url
|
||||
onView(withId(R.id.hostUrlInput))
|
||||
.perform(typeText(testServerURL), closeSoftKeyboard());
|
||||
onView(withId(R.id.account_username)).perform(click());
|
||||
|
||||
// Type user
|
||||
onView(withId(R.id.account_username))
|
||||
.perform(typeText(testUser), closeSoftKeyboard());
|
||||
|
||||
// Type user pass
|
||||
onView(withId(R.id.account_password))
|
||||
.perform(typeText(testPassword), closeSoftKeyboard());
|
||||
onView(withId(R.id.buttonOK)).perform(click());
|
||||
|
||||
// Check that the Activity ends after clicking
|
||||
|
||||
Thread.sleep(WAIT_LOGIN);
|
||||
Field f = Activity.class.getDeclaredField(RESULT_CODE);
|
||||
f.setAccessible(true);
|
||||
int mResultCode = f.getInt(mActivityRule.getActivity());
|
||||
|
||||
assertTrue(ERROR_MESSAGE, mResultCode == Activity.RESULT_OK);
|
||||
|
||||
}
|
||||
}
|
||||
//**
|
||||
// * ownCloud Android client application
|
||||
// *
|
||||
// * Copyright (C) 2015 ownCloud Inc.
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License version 2,
|
||||
// * as published by the Free Software Foundation.
|
||||
// *
|
||||
// * 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 General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// *
|
||||
// */
|
||||
//
|
||||
//package com.owncloud.android.authentication;
|
||||
//
|
||||
//import android.app.Activity;
|
||||
//import android.content.Context;
|
||||
//import android.content.Intent;
|
||||
//import android.os.Bundle;
|
||||
//import android.os.RemoteException;
|
||||
//import android.support.test.InstrumentationRegistry;
|
||||
//import android.support.test.rule.ActivityTestRule;
|
||||
//import android.support.test.runner.AndroidJUnit4;
|
||||
//import android.support.test.uiautomator.UiDevice;
|
||||
//import android.test.suitebuilder.annotation.LargeTest;
|
||||
//
|
||||
//import com.owncloud.android.R;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Rule;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//
|
||||
//import java.lang.reflect.Field;
|
||||
//
|
||||
//import static android.support.test.espresso.Espresso.onView;
|
||||
//import static android.support.test.espresso.action.ViewActions.click;
|
||||
//import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||
//import static android.support.test.espresso.action.ViewActions.typeText;
|
||||
//import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
//import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
|
||||
//import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
//import static org.hamcrest.Matchers.not;
|
||||
//import static org.junit.Assert.assertTrue;
|
||||
//
|
||||
//@RunWith(AndroidJUnit4.class)
|
||||
//@LargeTest
|
||||
//public class AuthenticatorActivityTest {
|
||||
//
|
||||
// public static final String EXTRA_ACTION = "ACTION";
|
||||
// public static final String EXTRA_ACCOUNT = "ACCOUNT";
|
||||
//
|
||||
// private static final int WAIT_LOGIN = 5000;
|
||||
//
|
||||
// private static final String ERROR_MESSAGE = "Activity not finished";
|
||||
// private static final String RESULT_CODE = "mResultCode";
|
||||
//
|
||||
//
|
||||
// @Rule
|
||||
// public ActivityTestRule<AuthenticatorActivity> mActivityRule = new ActivityTestRule<AuthenticatorActivity>(
|
||||
// AuthenticatorActivity.class){
|
||||
// @Override
|
||||
// protected Intent getActivityIntent() {
|
||||
//
|
||||
// Context targetContext = InstrumentationRegistry.getInstrumentation()
|
||||
// .getTargetContext();
|
||||
// Intent result = new Intent(targetContext, AuthenticatorActivity.class);
|
||||
// result.putExtra(EXTRA_ACTION, AuthenticatorActivity.ACTION_CREATE);
|
||||
// result.putExtra(EXTRA_ACCOUNT, "");
|
||||
// return result;
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// @Before
|
||||
// public void init(){
|
||||
// UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
|
||||
// /*Point[] coordinates = new Point[4];
|
||||
// coordinates[0] = new Point(248, 1020);
|
||||
// coordinates[1] = new Point(248, 429);
|
||||
// coordinates[2] = new Point(796, 1020);
|
||||
// coordinates[3] = new Point(796, 429);*/
|
||||
// try {
|
||||
// if (!uiDevice.isScreenOn()) {
|
||||
// uiDevice.wakeUp();
|
||||
// //uiDevice.swipe(coordinates, 10);
|
||||
// }
|
||||
// } catch (RemoteException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void checkLogin()
|
||||
// throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
|
||||
// Bundle arguments = InstrumentationRegistry.getArguments();
|
||||
//
|
||||
// // Get values passed
|
||||
// String testUser = arguments.getString("TEST_USER");
|
||||
// String testPassword = arguments.getString("TEST_PASSWORD");
|
||||
// String testServerURL = arguments.getString("TEST_SERVER_URL");
|
||||
//
|
||||
// // Check that login button is disabled
|
||||
// onView(withId(R.id.buttonOK))
|
||||
// .check(matches(not(isEnabled())));
|
||||
//
|
||||
// // Type server url
|
||||
// onView(withId(R.id.hostUrlInput))
|
||||
// .perform(typeText(testServerURL), closeSoftKeyboard());
|
||||
// onView(withId(R.id.account_username)).perform(click());
|
||||
//
|
||||
// // Type user
|
||||
// onView(withId(R.id.account_username))
|
||||
// .perform(typeText(testUser), closeSoftKeyboard());
|
||||
//
|
||||
// // Type user pass
|
||||
// onView(withId(R.id.account_password))
|
||||
// .perform(typeText(testPassword), closeSoftKeyboard());
|
||||
// onView(withId(R.id.buttonOK)).perform(click());
|
||||
//
|
||||
// // Check that the Activity ends after clicking
|
||||
//
|
||||
// Thread.sleep(WAIT_LOGIN);
|
||||
// Field f = Activity.class.getDeclaredField(RESULT_CODE);
|
||||
// f.setAccessible(true);
|
||||
// int mResultCode = f.getInt(mActivityRule.getActivity());
|
||||
//
|
||||
// assertTrue(ERROR_MESSAGE, mResultCode == Activity.RESULT_OK);
|
||||
//
|
||||
// }
|
||||
//}
|
|
@ -1,21 +1,20 @@
|
|||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
* <p>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
* <p>
|
||||
* 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 General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
|
@ -115,8 +114,8 @@ public class OCFileUnitTest {
|
|||
assertThat(fileReadFromParcel.getCreationTimestamp(), is(CREATION_TIMESTAMP));
|
||||
assertThat(fileReadFromParcel.getModificationTimestamp(), is(MODIFICATION_TIMESTAMP));
|
||||
assertThat(
|
||||
fileReadFromParcel.getModificationTimestampAtLastSyncForData(),
|
||||
is(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA)
|
||||
fileReadFromParcel.getModificationTimestampAtLastSyncForData(),
|
||||
is(MODIFICATION_TIMESTAMP_AT_LAST_SYNC_FOR_DATA)
|
||||
);
|
||||
assertThat(fileReadFromParcel.getLastSyncDateForProperties(), is(LAST_SYNC_DATE_FOR_PROPERTIES));
|
||||
assertThat(fileReadFromParcel.getLastSyncDateForData(), is(LAST_SYNC_DATE_FOR_DATA));
|
||||
|
|
|
@ -1,131 +1,131 @@
|
|||
package com.owncloud.android.screenshots;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.action.ViewActions;
|
||||
import android.support.test.espresso.contrib.DrawerActions;
|
||||
import android.support.test.espresso.matcher.PreferenceMatchers;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.Preferences;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
import tools.fastlane.screengrab.Screengrab;
|
||||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
|
||||
import tools.fastlane.screengrab.locale.LocaleTestRule;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onData;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.anything;
|
||||
import static org.hamcrest.core.AnyOf.anyOf;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class ScreenshotsIT {
|
||||
@ClassRule
|
||||
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<FileDisplayActivity> fileDisplayRule = new ActivityTestRule<>(FileDisplayActivity.class);
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<Preferences> preferencesRule = new ActivityTestRule<>(Preferences.class, true, false);
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gridViewScreenshot() throws InterruptedException {
|
||||
fileDisplayRule.launchActivity(new Intent());
|
||||
|
||||
Espresso.openContextualActionModeOverflowMenu();
|
||||
onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
Screengrab.screenshot("01_gridView");
|
||||
|
||||
Espresso.openContextualActionModeOverflowMenu();
|
||||
onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click());
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listViewScreenshot() throws InterruptedException {
|
||||
fileDisplayRule.launchActivity(new Intent());
|
||||
|
||||
// go into work folder
|
||||
onData(anything()).inAdapterView(withId(R.id.list_root)).atPosition(0).perform(click());
|
||||
|
||||
Screengrab.screenshot("02_listView");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void drawerScreenshot() throws InterruptedException {
|
||||
fileDisplayRule.launchActivity(new Intent());
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
Screengrab.screenshot("03_drawer");
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleAccountsScreenshot() throws InterruptedException {
|
||||
fileDisplayRule.launchActivity(new Intent());
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
onView(withId(R.id.drawer_active_user)).perform(click());
|
||||
|
||||
Screengrab.screenshot("04_accounts");
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void autoUploadScreenshot() throws InterruptedException {
|
||||
fileDisplayRule.launchActivity(new Intent());
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
onView(anyOf(withText(R.string.drawer_synced_folders), withId(R.id.nav_synced_folders))).perform(click());
|
||||
|
||||
Screengrab.screenshot("05_autoUpload");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
|
||||
@Test
|
||||
public void davdroidScreenshot() throws InterruptedException {
|
||||
preferencesRule.launchActivity(new Intent());
|
||||
|
||||
onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo());
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
Screengrab.screenshot("06_davdroid");
|
||||
|
||||
Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
}
|
||||
}
|
||||
//package com.owncloud.android.screenshots;
|
||||
//
|
||||
//import android.content.Intent;
|
||||
//import android.support.test.espresso.Espresso;
|
||||
//import android.support.test.espresso.action.ViewActions;
|
||||
//import android.support.test.espresso.contrib.DrawerActions;
|
||||
//import android.support.test.espresso.matcher.PreferenceMatchers;
|
||||
//import android.support.test.rule.ActivityTestRule;
|
||||
//
|
||||
//import com.owncloud.android.R;
|
||||
//import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
//import com.owncloud.android.ui.activity.Preferences;
|
||||
//
|
||||
//import junit.framework.Assert;
|
||||
//
|
||||
//import org.junit.BeforeClass;
|
||||
//import org.junit.ClassRule;
|
||||
//import org.junit.Rule;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//import org.junit.runners.JUnit4;
|
||||
//
|
||||
//import tools.fastlane.screengrab.Screengrab;
|
||||
//import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy;
|
||||
//import tools.fastlane.screengrab.locale.LocaleTestRule;
|
||||
//
|
||||
//import static android.support.test.espresso.Espresso.onData;
|
||||
//import static android.support.test.espresso.Espresso.onView;
|
||||
//import static android.support.test.espresso.action.ViewActions.click;
|
||||
//import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
//import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
//import static org.hamcrest.Matchers.anything;
|
||||
//import static org.hamcrest.core.AnyOf.anyOf;
|
||||
//
|
||||
//@RunWith(JUnit4.class)
|
||||
//public class ScreenshotsIT {
|
||||
// @ClassRule
|
||||
// public static final LocaleTestRule localeTestRule = new LocaleTestRule();
|
||||
//
|
||||
// @Rule
|
||||
// public ActivityTestRule<FileDisplayActivity> fileDisplayRule = new ActivityTestRule<>(FileDisplayActivity.class);
|
||||
//
|
||||
// @Rule
|
||||
// public ActivityTestRule<Preferences> preferencesRule = new ActivityTestRule<>(Preferences.class, true, false);
|
||||
//
|
||||
// @BeforeClass
|
||||
// public static void beforeAll() {
|
||||
// Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void gridViewScreenshot() throws InterruptedException {
|
||||
// fileDisplayRule.launchActivity(new Intent());
|
||||
//
|
||||
// Espresso.openContextualActionModeOverflowMenu();
|
||||
// onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click());
|
||||
//
|
||||
// Thread.sleep(1000);
|
||||
//
|
||||
// Screengrab.screenshot("01_gridView");
|
||||
//
|
||||
// Espresso.openContextualActionModeOverflowMenu();
|
||||
// onView(anyOf(withText(R.string.action_switch_list_view), withId(R.id.action_switch_view))).perform(click());
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void listViewScreenshot() throws InterruptedException {
|
||||
// fileDisplayRule.launchActivity(new Intent());
|
||||
//
|
||||
// // go into work folder
|
||||
// onData(anything()).inAdapterView(withId(R.id.list_root)).atPosition(0).perform(click());
|
||||
//
|
||||
// Screengrab.screenshot("02_listView");
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void drawerScreenshot() throws InterruptedException {
|
||||
// fileDisplayRule.launchActivity(new Intent());
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
//
|
||||
// Screengrab.screenshot("03_drawer");
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void multipleAccountsScreenshot() throws InterruptedException {
|
||||
// fileDisplayRule.launchActivity(new Intent());
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
// onView(withId(R.id.drawer_active_user)).perform(click());
|
||||
//
|
||||
// Screengrab.screenshot("04_accounts");
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.close());
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void autoUploadScreenshot() throws InterruptedException {
|
||||
// fileDisplayRule.launchActivity(new Intent());
|
||||
//
|
||||
// onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
// onView(anyOf(withText(R.string.drawer_synced_folders), withId(R.id.nav_synced_folders))).perform(click());
|
||||
//
|
||||
// Screengrab.screenshot("05_autoUpload");
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void davdroidScreenshot() throws InterruptedException {
|
||||
// preferencesRule.launchActivity(new Intent());
|
||||
//
|
||||
// onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo());
|
||||
//
|
||||
// Thread.sleep(1000);
|
||||
//
|
||||
// Screengrab.screenshot("06_davdroid");
|
||||
//
|
||||
// Assert.assertTrue(true); // if we reach this, everything is ok
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -18,24 +18,20 @@
|
|||
|
||||
package com.owncloud.android.uiautomator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SdkSuppress;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.test.uiautomator.By;
|
||||
import android.support.test.uiautomator.UiDevice;
|
||||
import android.support.test.uiautomator.UiObject;
|
||||
import android.support.test.uiautomator.UiObjectNotFoundException;
|
||||
import android.support.test.uiautomator.UiSelector;
|
||||
import android.support.test.uiautomator.Until;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -69,51 +65,51 @@ public class InitialTest {
|
|||
/**
|
||||
* Start owncloud app
|
||||
*/
|
||||
@Test
|
||||
public void startAppFromHomeScreen() {
|
||||
// Perform a short press on the HOME button
|
||||
mDevice.pressHome();
|
||||
|
||||
// Wait for launcher
|
||||
final String launcherPackage = getLauncherPackageName();
|
||||
assertThat(launcherPackage, notNullValue());
|
||||
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
|
||||
|
||||
// Launch the app
|
||||
Context context = InstrumentationRegistry.getContext();
|
||||
final Intent intent = context.getPackageManager()
|
||||
.getLaunchIntentForPackage(OWNCLOUD_APP_PACKAGE);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivity(intent);
|
||||
|
||||
// Wait for the app to appear
|
||||
mDevice.wait(Until.hasObject(By.pkg(OWNCLOUD_APP_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
|
||||
}
|
||||
// @Test
|
||||
// public void startAppFromHomeScreen() {
|
||||
// // Perform a short press on the HOME button
|
||||
// mDevice.pressHome();
|
||||
//
|
||||
// // Wait for launcher
|
||||
// final String launcherPackage = getLauncherPackageName();
|
||||
// assertThat(launcherPackage, notNullValue());
|
||||
// mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
|
||||
//
|
||||
// // Launch the app
|
||||
// Context context = InstrumentationRegistry.getContext();
|
||||
// final Intent intent = context.getPackageManager()
|
||||
// .getLaunchIntentForPackage(OWNCLOUD_APP_PACKAGE);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
// context.startActivity(intent);
|
||||
//
|
||||
// // Wait for the app to appear
|
||||
// mDevice.wait(Until.hasObject(By.pkg(OWNCLOUD_APP_PACKAGE).depth(0)), LAUNCH_TIMEOUT);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Start Settings app
|
||||
*
|
||||
* @throws UiObjectNotFoundException
|
||||
*/
|
||||
@Test
|
||||
public void startSettingsFromHomeScreen() throws UiObjectNotFoundException {
|
||||
|
||||
mDevice.pressHome();
|
||||
|
||||
// Wait for launcher
|
||||
final String launcherPackage = getLauncherPackageName();
|
||||
assertThat(launcherPackage, notNullValue());
|
||||
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
|
||||
|
||||
// Launch the app
|
||||
Context context = InstrumentationRegistry.getContext();
|
||||
final Intent intent = context.getPackageManager()
|
||||
.getLaunchIntentForPackage(ANDROID_SETTINGS_PACKAGE);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivity(intent);
|
||||
|
||||
clickByText(SETTINGS_DATA_USAGE_OPTION);
|
||||
}
|
||||
// @Test
|
||||
// public void startSettingsFromHomeScreen() throws UiObjectNotFoundException {
|
||||
//
|
||||
// mDevice.pressHome();
|
||||
//
|
||||
// // Wait for launcher
|
||||
// final String launcherPackage = getLauncherPackageName();
|
||||
// assertThat(launcherPackage, notNullValue());
|
||||
// mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)), LAUNCH_TIMEOUT);
|
||||
//
|
||||
// // Launch the app
|
||||
// Context context = InstrumentationRegistry.getContext();
|
||||
// final Intent intent = context.getPackageManager()
|
||||
// .getLaunchIntentForPackage(ANDROID_SETTINGS_PACKAGE);
|
||||
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
// context.startActivity(intent);
|
||||
//
|
||||
// clickByText(SETTINGS_DATA_USAGE_OPTION);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Uses package manager to find the package name of the device launcher. Usually this package
|
||||
|
|
|
@ -55,6 +55,7 @@ public class ErrorMessageAdapterUnitTest {
|
|||
private final static String MOCK_TO_DELETE = "to delete this file";
|
||||
private final static String PATH_TO_DELETE = "/path/to/a.file";
|
||||
private final static String EXPECTED_ERROR_MESSAGE = "You do not have permission to delete this file";
|
||||
private final static String ACCOUNT_TYPE = "nextcloud";
|
||||
|
||||
@Mock
|
||||
Resources mMockResources;
|
||||
|
@ -67,7 +68,7 @@ public class ErrorMessageAdapterUnitTest {
|
|||
when(mMockResources.getString(R.string.forbidden_permissions_delete))
|
||||
.thenReturn(MOCK_TO_DELETE);
|
||||
|
||||
Account account = new Account("name", MainApp.getAccountType());
|
||||
Account account = new Account("name", ACCOUNT_TYPE);
|
||||
|
||||
// ... when method under test is called ...
|
||||
String errorMessage = ErrorMessageAdapter.getErrorCauseMessage(
|
||||
|
|
|
@ -17,8 +17,8 @@ until [[ "$bootanim" =~ "stopped" ]]; do
|
|||
fi
|
||||
fi
|
||||
let "checkcounter += 1"
|
||||
sleep 10
|
||||
sleep 5
|
||||
done
|
||||
echo "($checkcounter) Done"
|
||||
adb -e shell input keyevent 82
|
||||
echo "($checkcounter) Unlocked emulator screen"
|
||||
echo "($checkcounter) Unlocked emulator screen"
|
||||
|
|
Загрузка…
Ссылка в новой задаче