diff options
author | cretin45 <cretin45@gmail.com> | 2015-01-15 16:04:44 -0800 |
---|---|---|
committer | cretin45 <cretin45@gmail.com> | 2015-01-15 16:04:44 -0800 |
commit | 0328b87bf68f6389049991c68caa515f4230f95f (patch) | |
tree | 556b0a23df4bb849eada991b01f4861c651f25e8 /tests | |
download | packages_apps_SetupWizard-0328b87bf68f6389049991c68caa515f4230f95f.zip packages_apps_SetupWizard-0328b87bf68f6389049991c68caa515f4230f95f.tar.gz packages_apps_SetupWizard-0328b87bf68f6389049991c68caa515f4230f95f.tar.bz2 |
SetupWizard: Initial commit
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Android.mk | 17 | ||||
-rw-r--r-- | tests/AndroidManifest.xml | 53 | ||||
-rw-r--r-- | tests/res/drawable/icon.png | bin | 0 -> 1980 bytes | |||
-rw-r--r-- | tests/res/layout/cmaccount_test.xml | 35 | ||||
-rw-r--r-- | tests/res/values/strings.xml | 21 | ||||
-rw-r--r-- | tests/src/com/cyanogenmod/account/tests/ManualTestActivity.java | 76 |
6 files changed, 202 insertions, 0 deletions
diff --git a/tests/Android.mk b/tests/Android.mk new file mode 100644 index 0000000..c67fc99 --- /dev/null +++ b/tests/Android.mk @@ -0,0 +1,17 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +# We only want this apk build for tests. +LOCAL_MODULE_TAGS := tests + +LOCAL_JAVA_LIBRARIES := android.test.runner + +# Include all test java files. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := CMSetupWizardTests +LOCAL_CERTIFICATE := platform + +LOCAL_INSTRUMENTATION_FOR := CMSetupWizard + +include $(BUILD_PACKAGE) diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml new file mode 100644 index 0000000..5e95a0f --- /dev/null +++ b/tests/AndroidManifest.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013 The CyanogenMod 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. +--> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.cyanogenmod.setupwizard.tests"> + <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> + <uses-permission android:name="android.permission.STATUS_BAR"/> + <uses-permission android:name="android.permission.WRITE_SETTINGS" /> + <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> > + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.GET_ACCOUNTS" /> + <uses-permission android:name="android.permission.USE_CREDENTIALS" /> + <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> + <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> + <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" /> + + <application android:icon="@drawable/icon"> + <uses-library android:name="android.test.runner" /> + <activity android:name="com.cyanogenmod.setupwizard.tests.ManualTestActivity" + android:label="@string/app_test" + android:theme="@android:style/Theme.Material.NoActionBar" + android:launchMode="singleTask"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + + <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" /> + + <instrumentation android:name="android.test.InstrumentationTestRunner" + android:targetPackage="com.cyanogenmod.setupwizard" + android:label="Tests for CMSetupWizard."/> + +</manifest> diff --git a/tests/res/drawable/icon.png b/tests/res/drawable/icon.png Binary files differnew file mode 100644 index 0000000..3cf3c4a --- /dev/null +++ b/tests/res/drawable/icon.png diff --git a/tests/res/layout/cmaccount_test.xml b/tests/res/layout/cmaccount_test.xml new file mode 100644 index 0000000..645b8bb --- /dev/null +++ b/tests/res/layout/cmaccount_test.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013 The CyanogenMod 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. +--> +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="match_parent" + android:layout_width="match_parent"> + <LinearLayout android:layout_height="match_parent" + android:layout_width="match_parent" + android:orientation="vertical"> + + <Button android:id="@+id/enable_setup" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:text="@string/enable_setup"/> + + <Button android:id="@+id/enable_google_setup" + android:layout_height="wrap_content" + android:layout_width="match_parent" + android:text="@string/enable_google_setup"/> + + </LinearLayout> +</ScrollView> diff --git a/tests/res/values/strings.xml b/tests/res/values/strings.xml new file mode 100644 index 0000000..94d85cb --- /dev/null +++ b/tests/res/values/strings.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2013 The CyanogenMod 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. +--> +<resources> + <string name="app_test">CMSetupWizard Test</string> + <string name="enable_setup">Enable Setup Wizard</string> + <string name="enable_google_setup">Enable Google Setup Wizard</string> +</resources> diff --git a/tests/src/com/cyanogenmod/account/tests/ManualTestActivity.java b/tests/src/com/cyanogenmod/account/tests/ManualTestActivity.java new file mode 100644 index 0000000..1e4adef --- /dev/null +++ b/tests/src/com/cyanogenmod/account/tests/ManualTestActivity.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2013 The CyanogenMod 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.cyanogenmod.setupwizard.tests; + + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.provider.Settings; +import android.view.View; + +public class ManualTestActivity extends Activity { + + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.cmaccount_test); + + findViewById(R.id.enable_setup).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + enableSetup(); + } + }); + findViewById(R.id.enable_google_setup).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + enableGoogleSetup(); + } + }); + } + + private void enableSetup() { + Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); + Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0); + Intent intent = new Intent("android.intent.action.MAIN"); + intent.addCategory("android.intent.category.HOME"); + final PackageManager pm = getPackageManager(); + ComponentName componentName = new ComponentName("com.cyanogenmod.account", "com.cyanogenmod.account.ui.SetupWizardActivity"); + pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); + componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); + pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); + startActivity(intent); + finish(); + } + + private void enableGoogleSetup() { + Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0); + Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 0); + Intent intent = new Intent("android.intent.action.MAIN"); + intent.addCategory("android.intent.category.HOME"); + final PackageManager pm = getPackageManager(); + ComponentName componentName = new ComponentName("com.google.android.setupwizard", "com.google.android.setupwizard.SetupWizardActivity"); + pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | intent.getFlags()); + startActivity(intent); + finish(); + } + +}
\ No newline at end of file |