diff --git a/tests/dummy_app/Android.mk b/tests/dummy_app/Android.mk new file mode 100644 index 0000000000..f4ab582ebf --- /dev/null +++ b/tests/dummy_app/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := samples + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := Aardwolf + +LOCAL_SDK_VERSION := current + +LOCAL_DEX_PREOPT := false + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/dummy_app/AndroidManifest.xml b/tests/dummy_app/AndroidManifest.xml new file mode 100644 index 0000000000..0546015a52 --- /dev/null +++ b/tests/dummy_app/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + diff --git a/tests/dummy_app/res/layout/empty_activity.xml b/tests/dummy_app/res/layout/empty_activity.xml new file mode 100644 index 0000000000..377c56bc36 --- /dev/null +++ b/tests/dummy_app/res/layout/empty_activity.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/tests/dummy_app/res/mipmap-anydpi/ic_launcher1.xml b/tests/dummy_app/res/mipmap-anydpi/ic_launcher1.xml new file mode 100644 index 0000000000..37c8c7387a --- /dev/null +++ b/tests/dummy_app/res/mipmap-anydpi/ic_launcher1.xml @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/tests/dummy_app/res/mipmap-anydpi/ic_launcher2.xml b/tests/dummy_app/res/mipmap-anydpi/ic_launcher2.xml new file mode 100644 index 0000000000..20b2986b6c --- /dev/null +++ b/tests/dummy_app/res/mipmap-anydpi/ic_launcher2.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher1.png b/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher1.png new file mode 100644 index 0000000000..73bc8e65b2 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher1.png differ diff --git a/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher2.png b/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher2.png new file mode 100644 index 0000000000..cd40b63c20 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxhdpi/ic_launcher2.png differ diff --git a/tests/dummy_app/res/mipmap-xxhdpi/icon_back_1.png b/tests/dummy_app/res/mipmap-xxhdpi/icon_back_1.png new file mode 100644 index 0000000000..8debef3fc7 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxhdpi/icon_back_1.png differ diff --git a/tests/dummy_app/res/mipmap-xxhdpi/icon_fore_1.png b/tests/dummy_app/res/mipmap-xxhdpi/icon_fore_1.png new file mode 100644 index 0000000000..de4079bd28 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxhdpi/icon_fore_1.png differ diff --git a/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher1.png b/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher1.png new file mode 100644 index 0000000000..889a99cfb7 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher1.png differ diff --git a/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher2.png b/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher2.png new file mode 100644 index 0000000000..973bb794b2 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxxhdpi/ic_launcher2.png differ diff --git a/tests/dummy_app/res/mipmap-xxxhdpi/icon_back_1.png b/tests/dummy_app/res/mipmap-xxxhdpi/icon_back_1.png new file mode 100644 index 0000000000..70c0ebd783 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxxhdpi/icon_back_1.png differ diff --git a/tests/dummy_app/res/mipmap-xxxhdpi/icon_fore_1.png b/tests/dummy_app/res/mipmap-xxxhdpi/icon_fore_1.png new file mode 100644 index 0000000000..9d91632113 Binary files /dev/null and b/tests/dummy_app/res/mipmap-xxxhdpi/icon_fore_1.png differ diff --git a/tests/dummy_app/res/values/colors.xml b/tests/dummy_app/res/values/colors.xml new file mode 100644 index 0000000000..b5ce66e9fb --- /dev/null +++ b/tests/dummy_app/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #455A64 + \ No newline at end of file diff --git a/tests/dummy_app/src/com/example/android/aardwolf/Activity1.java b/tests/dummy_app/src/com/example/android/aardwolf/Activity1.java new file mode 100644 index 0000000000..d4eab1545d --- /dev/null +++ b/tests/dummy_app/src/com/example/android/aardwolf/Activity1.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * 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.example.android.aardwolf; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; + +public class Activity1 extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + View view = getLayoutInflater().inflate(R.layout.empty_activity, null); + setContentView(view); + } +} + diff --git a/tests/res/raw/aardwolf_dummy_app.apk b/tests/res/raw/aardwolf_dummy_app.apk new file mode 100644 index 0000000000..39fb368ca9 Binary files /dev/null and b/tests/res/raw/aardwolf_dummy_app.apk differ diff --git a/tests/src/com/android/launcher3/util/TestUtil.java b/tests/src/com/android/launcher3/util/TestUtil.java new file mode 100644 index 0000000000..1338dcb108 --- /dev/null +++ b/tests/src/com/android/launcher3/util/TestUtil.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * 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.android.launcher3.util; + +import static androidx.test.InstrumentationRegistry.getContext; +import static androidx.test.InstrumentationRegistry.getInstrumentation; + +import android.content.res.Resources; + +import androidx.test.uiautomator.UiDevice; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +public class TestUtil { + public static void installDummyApp() throws IOException { + // Copy apk from resources to a local file and install from there. + final Resources resources = getContext().getResources(); + final InputStream in = resources.openRawResource( + resources.getIdentifier("aardwolf_dummy_app", + "raw", getContext().getPackageName())); + final String apkFilename = getInstrumentation().getTargetContext(). + getFilesDir().getPath() + "/dummy_app.apk"; + + final FileOutputStream out = new FileOutputStream(apkFilename); + byte[] buff = new byte[1024]; + int read; + + while ((read = in.read(buff)) > 0) { + out.write(buff, 0, read); + } + in.close(); + out.close(); + + UiDevice.getInstance(getInstrumentation()).executeShellCommand("pm install " + apkFilename); + } +}