Loading build.gradle +17 −4 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ buildscript { mavenCentral() mavenCentral() } } dependencies { dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.android.tools.build:gradle:+' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' } } } } Loading @@ -21,6 +21,9 @@ android { targetSdkVersion 23 targetSdkVersion 23 versionCode 1 versionCode 1 versionName "1.0" versionName "1.0" testApplicationId "com.android.launcher3.tests" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } } buildTypes { buildTypes { debug { debug { Loading @@ -30,10 +33,16 @@ android { sourceSets { sourceSets { main { main { res.srcDirs = ['res', 'WallpaperPicker/res'] res.srcDirs = ['res', 'WallpaperPicker/res'] main.java.srcDirs = ['src', 'WallpaperPicker/src'] java.srcDirs = ['src', 'WallpaperPicker/src'] manifest.srcFile 'AndroidManifest.xml' manifest.srcFile 'AndroidManifest.xml' proto.srcDirs 'protos/' proto.srcDirs 'protos/' } } androidTest { java.srcDirs = ['tests/src'] res.srcDirs = ['tests/res'] manifest.srcFile "tests/AndroidManifest.xml" } } } } } Loading @@ -42,9 +51,13 @@ repositories { } } dependencies { dependencies { compile 'com.android.support:support-v4:+' compile 'com.android.support:support-v4:23.0.1' compile 'com.android.support:recyclerview-v7:+' compile 'com.android.support:recyclerview-v7:23.0.1' compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2' compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test:runner:+' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:+' } } protobuf { protobuf { Loading tests/AndroidManifest.xml +5 −3 Original line number Original line Diff line number Diff line <?xml version="2.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 The Android Open Source Project <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -15,15 +15,17 @@ --> --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.android.launcher3.tests"> package="com.android.launcher3.tests"> <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/> <application> <application> <uses-library android:name="android.test.runner" /> <uses-library android:name="android.test.runner" /> </application> </application> <instrumentation <instrumentation android:name="android.test.InstrumentationTestRunner" android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.android.launcher3" android:targetPackage="com.android.launcher3" > android:label="Unit tests for Launcher3"> </instrumentation> </instrumentation> </manifest> </manifest> tests/src/com/android/launcher3/InvariantDeviceProfileTest.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,12 @@ public class InvariantDeviceProfileTest extends AndroidTestCase { public void testFindClosestDeviceProfile2() { public void testFindClosestDeviceProfile2() { for (InvariantDeviceProfile idf: mPredefinedDeviceProfiles) { for (InvariantDeviceProfile idf: mPredefinedDeviceProfiles) { ArrayList<InvariantDeviceProfile> predefinedProfilesCopy = new ArrayList<>(mPredefinedDeviceProfiles); ArrayList<InvariantDeviceProfile> closestProfiles = ArrayList<InvariantDeviceProfile> closestProfiles = mInvariantProfile.findClosestDeviceProfiles( mInvariantProfile.findClosestDeviceProfiles( idf.minWidthDps, idf.minHeightDps, mPredefinedDeviceProfiles); idf.minWidthDps, idf.minHeightDps, predefinedProfilesCopy ); assertTrue(closestProfiles.get(0).equals(idf)); assertTrue(closestProfiles.get(0).equals(idf)); } } } } Loading tests/src/com/android/launcher3/RotationPreferenceTest.java 0 → 100644 +87 −0 Original line number Original line Diff line number Diff line package com.android.launcher3; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Rect; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.Until; import android.test.InstrumentationTestCase; /** * Test for auto rotate preference. */ public class RotationPreferenceTest extends InstrumentationTestCase { private UiDevice mDevice; private Context mTargetContext; private String mTargetPackage; private SharedPreferences mPrefs; private boolean mOriginalRotationValue; @Override protected void setUp() throws Exception { super.setUp(); mDevice = UiDevice.getInstance(getInstrumentation()); mTargetContext = getInstrumentation().getTargetContext(); mTargetPackage = mTargetContext.getPackageName(); mPrefs = mTargetContext.getSharedPreferences( LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); mOriginalRotationValue = mPrefs.getBoolean(Utilities.ALLOW_ROTATION_PREFERENCE_KEY, false); } @Override protected void tearDown() throws Exception { setRotationEnabled(mOriginalRotationValue); super.tearDown(); } public void testRotation_disabled() throws Exception { if (mTargetContext.getResources().getBoolean(R.bool.allow_rotation)) { // This is a tablet. The test is only valid to mobile devices. return; } setRotationEnabled(false); mDevice.setOrientationRight(); goToLauncher(); Rect hotseat = getHotseatBounds(); assertTrue(hotseat.width() > hotseat.height()); } public void testRotation_enabled() throws Exception { if (mTargetContext.getResources().getBoolean(R.bool.allow_rotation)) { // This is a tablet. The test is only valid to mobile devices. return; } setRotationEnabled(true); mDevice.setOrientationRight(); goToLauncher(); Rect hotseat = getHotseatBounds(); assertTrue(hotseat.width() < hotseat.height()); } private void goToLauncher() { Intent homeIntent = new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME) .setPackage(mTargetPackage) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getInstrumentation().getContext().startActivity(homeIntent); mDevice.wait(Until.hasObject(By.pkg(mTargetPackage).depth(0)), 3000); } private void setRotationEnabled(boolean enabled) { mPrefs.edit().putBoolean(Utilities.ALLOW_ROTATION_PREFERENCE_KEY, enabled).commit(); } private Rect getHotseatBounds() { mDevice.wait(Until.hasObject(By.res(mTargetPackage, "hotseat")), 3000); return mDevice.findObject(By.res(mTargetPackage, "hotseat")).getVisibleBounds(); } } Loading
build.gradle +17 −4 Original line number Original line Diff line number Diff line Loading @@ -3,7 +3,7 @@ buildscript { mavenCentral() mavenCentral() } } dependencies { dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.android.tools.build:gradle:+' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' } } } } Loading @@ -21,6 +21,9 @@ android { targetSdkVersion 23 targetSdkVersion 23 versionCode 1 versionCode 1 versionName "1.0" versionName "1.0" testApplicationId "com.android.launcher3.tests" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } } buildTypes { buildTypes { debug { debug { Loading @@ -30,10 +33,16 @@ android { sourceSets { sourceSets { main { main { res.srcDirs = ['res', 'WallpaperPicker/res'] res.srcDirs = ['res', 'WallpaperPicker/res'] main.java.srcDirs = ['src', 'WallpaperPicker/src'] java.srcDirs = ['src', 'WallpaperPicker/src'] manifest.srcFile 'AndroidManifest.xml' manifest.srcFile 'AndroidManifest.xml' proto.srcDirs 'protos/' proto.srcDirs 'protos/' } } androidTest { java.srcDirs = ['tests/src'] res.srcDirs = ['tests/res'] manifest.srcFile "tests/AndroidManifest.xml" } } } } } Loading @@ -42,9 +51,13 @@ repositories { } } dependencies { dependencies { compile 'com.android.support:support-v4:+' compile 'com.android.support:support-v4:23.0.1' compile 'com.android.support:recyclerview-v7:+' compile 'com.android.support:recyclerview-v7:23.0.1' compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2' compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2' testCompile 'junit:junit:4.12' androidTestCompile 'com.android.support.test:runner:+' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:+' } } protobuf { protobuf { Loading
tests/AndroidManifest.xml +5 −3 Original line number Original line Diff line number Diff line <?xml version="2.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2015 The Android Open Source Project <!-- Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -15,15 +15,17 @@ --> --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.android.launcher3.tests"> package="com.android.launcher3.tests"> <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/> <application> <application> <uses-library android:name="android.test.runner" /> <uses-library android:name="android.test.runner" /> </application> </application> <instrumentation <instrumentation android:name="android.test.InstrumentationTestRunner" android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.android.launcher3" android:targetPackage="com.android.launcher3" > android:label="Unit tests for Launcher3"> </instrumentation> </instrumentation> </manifest> </manifest>
tests/src/com/android/launcher3/InvariantDeviceProfileTest.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,12 @@ public class InvariantDeviceProfileTest extends AndroidTestCase { public void testFindClosestDeviceProfile2() { public void testFindClosestDeviceProfile2() { for (InvariantDeviceProfile idf: mPredefinedDeviceProfiles) { for (InvariantDeviceProfile idf: mPredefinedDeviceProfiles) { ArrayList<InvariantDeviceProfile> predefinedProfilesCopy = new ArrayList<>(mPredefinedDeviceProfiles); ArrayList<InvariantDeviceProfile> closestProfiles = ArrayList<InvariantDeviceProfile> closestProfiles = mInvariantProfile.findClosestDeviceProfiles( mInvariantProfile.findClosestDeviceProfiles( idf.minWidthDps, idf.minHeightDps, mPredefinedDeviceProfiles); idf.minWidthDps, idf.minHeightDps, predefinedProfilesCopy ); assertTrue(closestProfiles.get(0).equals(idf)); assertTrue(closestProfiles.get(0).equals(idf)); } } } } Loading
tests/src/com/android/launcher3/RotationPreferenceTest.java 0 → 100644 +87 −0 Original line number Original line Diff line number Diff line package com.android.launcher3; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Rect; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.Until; import android.test.InstrumentationTestCase; /** * Test for auto rotate preference. */ public class RotationPreferenceTest extends InstrumentationTestCase { private UiDevice mDevice; private Context mTargetContext; private String mTargetPackage; private SharedPreferences mPrefs; private boolean mOriginalRotationValue; @Override protected void setUp() throws Exception { super.setUp(); mDevice = UiDevice.getInstance(getInstrumentation()); mTargetContext = getInstrumentation().getTargetContext(); mTargetPackage = mTargetContext.getPackageName(); mPrefs = mTargetContext.getSharedPreferences( LauncherAppState.getSharedPreferencesKey(), Context.MODE_PRIVATE); mOriginalRotationValue = mPrefs.getBoolean(Utilities.ALLOW_ROTATION_PREFERENCE_KEY, false); } @Override protected void tearDown() throws Exception { setRotationEnabled(mOriginalRotationValue); super.tearDown(); } public void testRotation_disabled() throws Exception { if (mTargetContext.getResources().getBoolean(R.bool.allow_rotation)) { // This is a tablet. The test is only valid to mobile devices. return; } setRotationEnabled(false); mDevice.setOrientationRight(); goToLauncher(); Rect hotseat = getHotseatBounds(); assertTrue(hotseat.width() > hotseat.height()); } public void testRotation_enabled() throws Exception { if (mTargetContext.getResources().getBoolean(R.bool.allow_rotation)) { // This is a tablet. The test is only valid to mobile devices. return; } setRotationEnabled(true); mDevice.setOrientationRight(); goToLauncher(); Rect hotseat = getHotseatBounds(); assertTrue(hotseat.width() < hotseat.height()); } private void goToLauncher() { Intent homeIntent = new Intent(Intent.ACTION_MAIN) .addCategory(Intent.CATEGORY_HOME) .setPackage(mTargetPackage) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getInstrumentation().getContext().startActivity(homeIntent); mDevice.wait(Until.hasObject(By.pkg(mTargetPackage).depth(0)), 3000); } private void setRotationEnabled(boolean enabled) { mPrefs.edit().putBoolean(Utilities.ALLOW_ROTATION_PREFERENCE_KEY, enabled).commit(); } private Rect getHotseatBounds() { mDevice.wait(Until.hasObject(By.res(mTargetPackage, "hotseat")), 3000); return mDevice.findObject(By.res(mTargetPackage, "hotseat")).getVisibleBounds(); } }