1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.assist.cts; 18 19 import android.assist.common.Utils; 20 21 import android.app.Activity; 22 import android.app.assist.AssistStructure; 23 import android.app.assist.AssistStructure.ViewNode; 24 import android.content.Intent; 25 import android.content.ComponentName; 26 import android.os.Bundle; 27 import android.util.Log; 28 import android.view.View; 29 import android.view.ViewGroup; 30 import android.view.Window; 31 import android.widget.TextView; 32 33 public class TestStartActivity extends Activity { 34 static final String TAG = "TestStartActivity"; 35 36 @Override onCreate(Bundle savedInstanceState)37 public void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 Log.i(TAG, " in onCreate"); 40 41 // Set the respective view we want compared with the test activity 42 String testCaseName = getIntent().getStringExtra(Utils.TESTCASE_TYPE); 43 switch (testCaseName) { 44 case Utils.ASSIST_STRUCTURE: 45 setContentView(R.layout.test_app); 46 setTitle(R.string.testAppTitle); 47 return; 48 } 49 } 50 51 @Override onResume()52 protected void onResume() { 53 super.onResume(); 54 Log.i(TAG, " in onResume"); 55 } 56 startTest(String testCaseName)57 public void startTest(String testCaseName) { 58 Log.i(TAG, "Starting test activity for TestCaseType = " + testCaseName); 59 Intent intent = new Intent(); 60 intent.putExtra(Utils.TESTCASE_TYPE, testCaseName); 61 intent.setAction("android.intent.action.START_TEST_" + testCaseName); 62 intent.setComponent(new ComponentName("android.assist.service", 63 "android.assist." + Utils.getTestActivity(testCaseName))); 64 startActivity(intent); 65 } 66 start3pApp(String testCaseName)67 public void start3pApp(String testCaseName) { 68 Intent intent = new Intent(); 69 intent.setAction("android.intent.action.TEST_APP_" + testCaseName); 70 intent.setComponent(Utils.getTestAppComponent(testCaseName)); 71 startActivity(intent); 72 } 73 start3pAppWithColor(String testCaseName, int color)74 public void start3pAppWithColor(String testCaseName, int color) { 75 Intent intent = new Intent(); 76 intent.setAction("android.intent.action.TEST_APP_" + testCaseName); 77 intent.putExtra(Utils.SCREENSHOT_COLOR_KEY, color); 78 intent.setComponent(Utils.getTestAppComponent(testCaseName)); 79 startActivity(intent); 80 } 81 onPause()82 @Override protected void onPause() { 83 Log.i(TAG, " in onPause"); 84 super.onPause(); 85 } 86 onStart()87 @Override protected void onStart() { 88 super.onStart(); 89 Log.i(TAG, " in onStart"); 90 } 91 onRestart()92 @Override protected void onRestart() { 93 super.onRestart(); 94 Log.i(TAG, " in onRestart"); 95 } 96 onStop()97 @Override protected void onStop() { 98 Log.i(TAG, " in onStop"); 99 super.onStop(); 100 } 101 102 @Override onDestroy()103 protected void onDestroy() { 104 Log.i(TAG, " in onDestroy"); 105 super.onDestroy(); 106 } 107 } 108