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.widget.layout.linear;
18
19import android.app.Activity;
20import android.test.ActivityInstrumentationTestCase;
21import android.test.suitebuilder.annotation.MediumTest;
22import android.view.View;
23
24import com.android.frameworks.coretests.R;
25import android.widget.layout.linear.WeightSum;
26
27public class WeightSumTest extends ActivityInstrumentationTestCase<WeightSum> {
28    private View mChild;
29    private View mContainer;
30
31    public WeightSumTest() {
32        super("com.android.frameworks.coretests", WeightSum.class);
33    }
34
35    @Override
36    protected void setUp() throws Exception {
37        super.setUp();
38
39        final Activity activity = getActivity();
40        mChild = activity.findViewById(R.id.child);
41        mContainer = activity.findViewById(R.id.container);
42    }
43
44    @MediumTest
45    public void testPreconditions() {
46        assertNotNull(mChild);
47        assertNotNull(mContainer);
48    }
49
50    @MediumTest
51    public void testLayout() {
52        final int childWidth = mChild.getWidth();
53        final int containerWidth = mContainer.getWidth();
54
55        assertEquals(containerWidth / 2, childWidth);
56    }
57}
58