| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.appmenu; | 5 package org.chromium.chrome.browser.appmenu; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 import android.view.KeyEvent; | 10 import android.view.KeyEvent; |
| 11 import android.view.MenuItem; | 11 import android.view.MenuItem; |
| 12 import android.view.View; | 12 import android.view.View; |
| 13 import android.widget.ListPopupWindow; | 13 import android.widget.ListPopupWindow; |
| 14 import android.widget.ListView; | 14 import android.widget.ListView; |
| 15 | 15 |
| 16 import org.chromium.base.ThreadUtils; | 16 import org.chromium.base.ThreadUtils; |
| 17 import org.chromium.base.annotations.SuppressFBWarnings; |
| 17 import org.chromium.base.test.util.DisabledTest; | 18 import org.chromium.base.test.util.DisabledTest; |
| 18 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
| 19 import org.chromium.chrome.shell.ChromeShellActivity; | 20 import org.chromium.chrome.shell.ChromeShellActivity; |
| 20 import org.chromium.chrome.shell.ChromeShellActivity.AppMenuHandlerFactory; | 21 import org.chromium.chrome.shell.ChromeShellActivity.AppMenuHandlerFactory; |
| 21 import org.chromium.chrome.shell.ChromeShellTestBase; | 22 import org.chromium.chrome.shell.ChromeShellTestBase; |
| 22 import org.chromium.chrome.shell.R; | 23 import org.chromium.chrome.shell.R; |
| 23 import org.chromium.content.browser.test.util.Criteria; | 24 import org.chromium.content.browser.test.util.Criteria; |
| 24 import org.chromium.content.browser.test.util.CriteriaHelper; | 25 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 25 | 26 |
| 26 /** | 27 /** |
| 27 * Tests AppMenu popup | 28 * Tests AppMenu popup |
| 28 */ | 29 */ |
| 29 public class AppMenuTest extends ChromeShellTestBase { | 30 public class AppMenuTest extends ChromeShellTestBase { |
| 30 private AppMenu mAppMenu; | 31 private AppMenu mAppMenu; |
| 31 private AppMenuHandlerForTest mAppMenuHandler; | 32 private AppMenuHandlerForTest mAppMenuHandler; |
| 32 | 33 |
| 33 /** | 34 /** |
| 34 * AppMenuHandler that will be used to intercept item selections for testing
. | 35 * AppMenuHandler that will be used to intercept item selections for testing
. |
| 35 */ | 36 */ |
| 37 @SuppressFBWarnings("URF_UNREAD_FIELD") |
| 36 public static class AppMenuHandlerForTest extends AppMenuHandler { | 38 public static class AppMenuHandlerForTest extends AppMenuHandler { |
| 37 int mLastSelectedItemId = -1; | 39 int mLastSelectedItemId = -1; |
| 38 | 40 |
| 39 /** | 41 /** |
| 40 * AppMenuHandler for intercepting options item selections. | 42 * AppMenuHandler for intercepting options item selections. |
| 41 */ | 43 */ |
| 42 public AppMenuHandlerForTest(Activity activity, AppMenuPropertiesDelegat
e delegate, | 44 public AppMenuHandlerForTest(Activity activity, AppMenuPropertiesDelegat
e delegate, |
| 43 int menuResourceId) { | 45 int menuResourceId) { |
| 44 super(activity, delegate, menuResourceId); | 46 super(activity, delegate, menuResourceId); |
| 45 } | 47 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 ListView listView = popup.getListView(); | 259 ListView listView = popup.getListView(); |
| 258 return listView.getSelectedItemPosition(); | 260 return listView.getSelectedItemPosition(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 private int getCount() { | 263 private int getCount() { |
| 262 ListPopupWindow popup = mAppMenu.getPopup(); | 264 ListPopupWindow popup = mAppMenu.getPopup(); |
| 263 if (popup == null || popup.getListView() == null) return 0; | 265 if (popup == null || popup.getListView() == null) return 0; |
| 264 return popup.getListView().getCount(); | 266 return popup.getListView().getCount(); |
| 265 } | 267 } |
| 266 } | 268 } |
| OLD | NEW |