1/*
2 * Copyright (C) 2007 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.view;
18
19import com.android.frameworks.coretests.R;
20
21import android.os.Bundle;
22import android.app.Activity;
23import android.widget.LinearLayout;
24import android.widget.ScrollView;
25import android.view.ViewGroup;
26import android.view.View;
27import android.view.Display;
28import android.view.ViewConfiguration;
29
30/**
31 * This activity contains two Views, one as big as the screen, one much larger. The large one
32 * should not be able to activate its drawing cache.
33 */
34public class BigCache extends Activity {
35    @Override
36    protected void onCreate(Bundle icicle) {
37        super.onCreate(icicle);
38
39        final LinearLayout testBed = new LinearLayout(this);
40        testBed.setOrientation(LinearLayout.VERTICAL);
41        testBed.setLayoutParams(new ViewGroup.LayoutParams(
42                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
43
44        final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
45        final Display display = getWindowManager().getDefaultDisplay();
46        final int screenWidth = display.getWidth();
47        final int screenHeight = display.getHeight();
48
49        final View tiny = new View(this);
50        tiny.setId(R.id.a);
51        tiny.setBackgroundColor(0xFFFF0000);
52        tiny.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight));
53
54        final View large = new View(this);
55        large.setId(R.id.b);
56        large.setBackgroundColor(0xFF00FF00);
57        // Compute the height of the view assuming a cache size based on ARGB8888
58        final int height = 2 * (cacheSize / 2) / screenWidth;
59        large.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, height));
60
61        final ScrollView scroller = new ScrollView(this);
62        scroller.setLayoutParams(new ViewGroup.LayoutParams(
63                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
64
65        testBed.addView(tiny);
66        testBed.addView(large);
67        scroller.addView(testBed);
68
69        setContentView(scroller);
70    }
71}
72