blob: e0f83ccee7e8a79a421ecc4d7d65cd19b202f0c4 [file] [log] [blame]
Alice Leed71a07b2015-07-29 14:30:56 -07001/*
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
17package android.assist.testapp;
18
Alice Lee0cad7a12015-08-19 14:54:54 -070019import android.assist.common.Utils;
20
Alice Leed71a07b2015-07-29 14:30:56 -070021import android.app.Activity;
Alice Lee0cad7a12015-08-19 14:54:54 -070022import android.content.Intent;
Alice Leeeb39d692015-08-25 14:29:16 -070023import android.graphics.Bitmap;
24import android.os.Bundle;
25import android.util.Log;
26import android.view.View;
27import android.view.View.MeasureSpec;
28import android.view.ViewGroup;
29import android.view.ViewTreeObserver;
30import android.view.ViewTreeObserver.OnGlobalLayoutListener;
31
32import java.io.ByteArrayOutputStream;
Alice Leed71a07b2015-07-29 14:30:56 -070033import android.os.Bundle;
Alice Leed71a07b2015-07-29 14:30:56 -070034import android.util.Log;
Alice Lee0cad7a12015-08-19 14:54:54 -070035import android.view.View;
36import android.view.ViewTreeObserver;
37import android.view.ViewTreeObserver.OnGlobalLayoutListener;
38
39import java.lang.Override;
Alice Leed71a07b2015-07-29 14:30:56 -070040
Alice Leed71a07b2015-07-29 14:30:56 -070041public class TestApp extends Activity {
Alice Lee69f4ec42015-08-05 14:17:57 -070042 static final String TAG = "TestApp";
Alice Leed71a07b2015-07-29 14:30:56 -070043
Alice Leee4839c32015-09-04 15:11:35 -070044 private String mTestCaseName;
45
Alice Lee69f4ec42015-08-05 14:17:57 -070046 @Override
47 public void onCreate(Bundle savedInstanceState) {
48 super.onCreate(savedInstanceState);
49 Log.i(TAG, "TestApp created");
Alice Leee4839c32015-09-04 15:11:35 -070050 mTestCaseName = getIntent().getStringExtra(Utils.TESTCASE_TYPE);
51 switch (mTestCaseName) {
52 case Utils.LARGE_VIEW_HIERARCHY:
53 setContentView(R.layout.multiple_text_views);
54 return;
55 default:
56 setContentView(R.layout.test_app);
57 }
Alice Lee69f4ec42015-08-05 14:17:57 -070058 }
59
60 @Override
61 public void onResume() {
62 super.onResume();
Alice Lee0cad7a12015-08-19 14:54:54 -070063 Log.i(TAG, "TestApp has resumed");
64 final View layout = findViewById(android.R.id.content);
65 ViewTreeObserver vto = layout.getViewTreeObserver();
66 vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
67 @Override
68 public void onGlobalLayout() {
69 layout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
Alice Leee4839c32015-09-04 15:11:35 -070070 sendBroadcast(new Intent(Utils.APP_3P_HASRESUMED));
Alice Lee0cad7a12015-08-19 14:54:54 -070071 }
72 });
Alice Lee69f4ec42015-08-05 14:17:57 -070073 }
74}