1/*
2 * Copyright (C) 2010 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 com.android.gallery3d.ui;
18
19class GLViewMock extends GLView {
20    // onAttachToRoot
21    int mOnAttachCalled;
22    GLRoot mRoot;
23    // onDetachFromRoot
24    int mOnDetachCalled;
25    // onVisibilityChanged
26    int mOnVisibilityChangedCalled;
27    // onLayout
28    int mOnLayoutCalled;
29    boolean mOnLayoutChangeSize;
30    // renderBackground
31    int mRenderBackgroundCalled;
32    // onMeasure
33    int mOnMeasureCalled;
34    int mOnMeasureWidthSpec;
35    int mOnMeasureHeightSpec;
36
37    @Override
38    public void onAttachToRoot(GLRoot root) {
39        mRoot = root;
40        mOnAttachCalled++;
41        super.onAttachToRoot(root);
42    }
43
44    @Override
45    public void onDetachFromRoot() {
46        mRoot = null;
47        mOnDetachCalled++;
48        super.onDetachFromRoot();
49    }
50
51    @Override
52    protected void onVisibilityChanged(int visibility) {
53        mOnVisibilityChangedCalled++;
54    }
55
56    @Override
57    protected void onLayout(boolean changeSize, int left, int top,
58            int right, int bottom) {
59        mOnLayoutCalled++;
60        mOnLayoutChangeSize = changeSize;
61        // call children's layout.
62        for (int i = 0, n = getComponentCount(); i < n; ++i) {
63            GLView item = getComponent(i);
64            item.layout(left, top, right, bottom);
65        }
66    }
67
68    @Override
69    protected void onMeasure(int widthSpec, int heightSpec) {
70        mOnMeasureCalled++;
71        mOnMeasureWidthSpec = widthSpec;
72        mOnMeasureHeightSpec = heightSpec;
73        // call children's measure.
74        for (int i = 0, n = getComponentCount(); i < n; ++i) {
75            GLView item = getComponent(i);
76            item.measure(widthSpec, heightSpec);
77        }
78        setMeasuredSize(widthSpec, heightSpec);
79    }
80
81    @Override
82    protected void renderBackground(GLCanvas view) {
83        mRenderBackgroundCalled++;
84    }
85}
86