2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.widget.focus;
19 import android.widget.focus.HorizontalFocusSearch;
21 import android.test.ActivityInstrumentationTestCase;
22 import android.test.suitebuilder.annotation.Suppress;
23 import android.widget.LinearLayout;
24 import android.widget.Button;
25 import android.view.View;
27 import static android.widget.focus.VerticalFocusSearchTest.FocusSearchAlg;
28 import static android.widget.focus.VerticalFocusSearchTest.NewFocusSearchAlg;
31 * Tests that focus searching works on a horizontal linear layout of buttons of
32 * various widths and vertical placements.
34 // Suppress until bug http://b/issue?id=1416545 is fixed.
36 public class HorizontalFocusSearchTest extends ActivityInstrumentationTestCase<HorizontalFocusSearch> {
38 private FocusSearchAlg mFocusFinder;
40 private LinearLayout mLayout;
41 private Button mLeftTall;
42 private Button mMidShort1Top;
43 private Button mMidShort2Bottom;
44 private Button mRightTall;
47 public HorizontalFocusSearchTest() {
48 super("com.android.frameworks.coretests", HorizontalFocusSearch.class);
52 protected void setUp() throws Exception {
55 mFocusFinder = new NewFocusSearchAlg();
57 mLayout = getActivity().getLayout();
58 mLeftTall = getActivity().getLeftTall();
59 mMidShort1Top = getActivity().getMidShort1Top();
60 mMidShort2Bottom = getActivity().getMidShort2Bottom();
61 mRightTall = getActivity().getRightTall();
64 public void testPreconditions() {
65 assertNotNull(mLayout);
66 assertNotNull(mLeftTall);
67 assertNotNull(mMidShort1Top);
68 assertNotNull(mMidShort2Bottom);
69 assertNotNull(mRightTall);
72 public void testSearchFromLeftButton() {
73 assertNull("going up from mLeftTall",
74 mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_UP));
75 assertNull("going down from mLeftTall",
76 mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_DOWN));
77 assertNull("going left from mLeftTall",
78 mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_LEFT));
80 assertEquals("going right from mLeftTall",
82 mFocusFinder.findNextFocus(mLayout, mLeftTall, View.FOCUS_RIGHT));
85 public void TODO_testSearchFromMiddleLeftButton() {
86 assertNull("going up from mMidShort1Top",
87 mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_UP));
88 assertEquals("going down from mMidShort1Top",
90 mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_DOWN));
91 assertEquals("going left from mMidShort1Top",
93 mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_LEFT));
94 assertEquals("going right from mMidShort1Top",
96 mFocusFinder.findNextFocus(mLayout, mMidShort1Top, View.FOCUS_RIGHT));
99 public void TODO_testSearchFromMiddleRightButton() {
100 assertEquals("going up from mMidShort2Bottom",
102 mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_UP));
103 assertNull("going down from mMidShort2Bottom",
104 mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_DOWN));
105 assertEquals("going left from mMidShort2Bottom",
107 mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_LEFT));
108 assertEquals("goind right from mMidShort2Bottom",
110 mFocusFinder.findNextFocus(mLayout, mMidShort2Bottom, View.FOCUS_RIGHT));
113 public void testSearchFromRightButton() {
114 assertNull("going up from mRightTall",
115 mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_UP));
116 assertNull("going down from mRightTall",
117 mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_DOWN));
118 assertEquals("going left from mRightTall",
120 mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_LEFT));
121 assertNull("going right from mRightTall",
122 mFocusFinder.findNextFocus(mLayout, mRightTall, View.FOCUS_RIGHT));