| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_app_list_view_presenter_impl.h" | 12 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/test/scoped_feature_list.h" | 16 #include "base/test/scoped_feature_list.h" |
| 17 #include "ui/app_list/app_list_features.h" | 17 #include "ui/app_list/app_list_features.h" |
| 18 #include "ui/app_list/app_list_switches.h" | 18 #include "ui/app_list/app_list_switches.h" |
| 19 #include "ui/app_list/views/app_list_main_view.h" | 19 #include "ui/app_list/views/app_list_main_view.h" |
| 20 #include "ui/app_list/views/app_list_view.h" | 20 #include "ui/app_list/views/app_list_view.h" |
| 21 #include "ui/app_list/views/search_box_view.h" |
| 21 #include "ui/aura/test/test_windows.h" | 22 #include "ui/aura/test/test_windows.h" |
| 22 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| 23 #include "ui/display/display.h" | 24 #include "ui/display/display.h" |
| 24 #include "ui/display/screen.h" | 25 #include "ui/display/screen.h" |
| 25 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
| 27 #include "ui/views/controls/textfield/textfield.h" |
| 26 | 28 |
| 27 namespace ash { | 29 namespace ash { |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 int64_t GetPrimaryDisplayId() { | 32 int64_t GetPrimaryDisplayId() { |
| 31 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); | 33 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 225 |
| 224 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); | 226 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 225 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); | 227 EXPECT_TRUE(app_list_presenter_impl()->GetTargetVisibility()); |
| 226 | 228 |
| 227 // Clicking outside the bounds closes the app list. | 229 // Clicking outside the bounds closes the app list. |
| 228 generator.MoveMouseTo(tap_point); | 230 generator.MoveMouseTo(tap_point); |
| 229 generator.ClickLeftButton(); | 231 generator.ClickLeftButton(); |
| 230 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); | 232 EXPECT_FALSE(app_list_presenter_impl()->GetTargetVisibility()); |
| 231 } | 233 } |
| 232 | 234 |
| 235 // Tests that a keypress activates the searchbox and that clearing the searchbox |
| 236 // deactivates the searchbox. |
| 237 TEST_F(AppListPresenterDelegateTest, KeyPressEnablesSearchBox) { |
| 238 EnableFullscreenAppList(); |
| 239 |
| 240 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 241 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 242 app_list::SearchBoxView* search_box_view = |
| 243 app_list_presenter_impl()->GetView()->search_box_view(); |
| 244 EXPECT_FALSE(search_box_view->is_search_box_active()); |
| 245 |
| 246 // Press any key, the search box cursor should enable and the placeholder text |
| 247 // should be aligned left |
| 248 generator.PressKey(ui::VKEY_0, 0); |
| 249 EXPECT_TRUE(search_box_view->is_search_box_active()); |
| 250 |
| 251 // Delete the text, the cursor should return to its previous state with the |
| 252 // placeholder text back in place. |
| 253 search_box_view->ClearSearch(); |
| 254 EXPECT_FALSE(search_box_view->is_search_box_active()); |
| 255 } |
| 256 |
| 257 // Tests that the searchbox activates when it is clicked and that the widget is |
| 258 // closed after clicking outside the searchbox. |
| 259 TEST_F(AppListPresenterDelegateTest, ClickEnablesSearchBox) { |
| 260 EnableFullscreenAppList(); |
| 261 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 262 app_list::SearchBoxView* search_box_view = |
| 263 app_list_presenter_impl()->GetView()->search_box_view(); |
| 264 |
| 265 // Click the searchbox, the search box should be active. |
| 266 gfx::Point search_box_point = |
| 267 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); |
| 268 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 269 generator.MoveMouseTo(search_box_point); |
| 270 generator.PressLeftButton(); |
| 271 generator.ReleaseLeftButton(); |
| 272 EXPECT_TRUE(search_box_view->is_search_box_active()); |
| 273 |
| 274 // Click outside the search box, the widget should close. |
| 275 gfx::Point app_list_point = app_list_presenter_impl() |
| 276 ->GetView() |
| 277 ->GetWidget() |
| 278 ->GetWindowBoundsInScreen() |
| 279 .CenterPoint(); |
| 280 generator.MoveMouseTo(app_list_point); |
| 281 generator.PressLeftButton(); |
| 282 generator.ReleaseLeftButton(); |
| 283 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); |
| 284 } |
| 285 |
| 286 // Tests that the searchbox activates when it is tapped and that the widget is |
| 287 // closed after tapping outside the searchbox. |
| 288 TEST_F(AppListPresenterDelegateTest, TapEnablesSearchBox) { |
| 289 EnableFullscreenAppList(); |
| 290 app_list_presenter_impl()->Show(GetPrimaryDisplayId()); |
| 291 app_list::SearchBoxView* search_box_view = |
| 292 app_list_presenter_impl()->GetView()->search_box_view(); |
| 293 |
| 294 // Tap the search box, it should activate. |
| 295 gfx::Point search_box_point = |
| 296 search_box_view->search_box()->GetBoundsInScreen().CenterPoint(); |
| 297 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 298 generator.GestureTapAt(search_box_point); |
| 299 EXPECT_TRUE(search_box_view->is_search_box_active()); |
| 300 |
| 301 // Tap on the body of the app list, the app list should hide. |
| 302 gfx::Point app_list_point = app_list_presenter_impl() |
| 303 ->GetView() |
| 304 ->GetWidget() |
| 305 ->GetWindowBoundsInScreen() |
| 306 .CenterPoint(); |
| 307 generator.GestureTapAt(app_list_point); |
| 308 EXPECT_FALSE(app_list_presenter_impl()->IsVisible()); |
| 309 } |
| 233 } // namespace ash | 310 } // namespace ash |
| OLD | NEW |