OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/common/shelf/app_list_button.h" | 12 #include "ash/common/shelf/app_list_button.h" |
13 #include "ash/common/shelf/overflow_bubble.h" | 13 #include "ash/common/shelf/overflow_bubble.h" |
14 #include "ash/common/shelf/overflow_bubble_view.h" | 14 #include "ash/common/shelf/overflow_bubble_view.h" |
15 #include "ash/common/shelf/shelf_constants.h" | 15 #include "ash/common/shelf/shelf_constants.h" |
16 #include "ash/common/shelf/shelf_item_delegate_manager.h" | |
17 #include "ash/common/shelf/shelf_menu_model.h" | 16 #include "ash/common/shelf/shelf_menu_model.h" |
18 #include "ash/common/shelf/shelf_model.h" | 17 #include "ash/common/shelf/shelf_model.h" |
19 #include "ash/common/shell_window_ids.h" | 18 #include "ash/common/shell_window_ids.h" |
20 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
21 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
22 #include "ash/shelf/shelf.h" | 21 #include "ash/shelf/shelf.h" |
23 #include "ash/shelf/shelf_button.h" | 22 #include "ash/shelf/shelf_button.h" |
24 #include "ash/shelf/shelf_icon_observer.h" | 23 #include "ash/shelf/shelf_icon_observer.h" |
25 #include "ash/shelf/shelf_tooltip_manager.h" | 24 #include "ash/shelf/shelf_tooltip_manager.h" |
26 #include "ash/shelf/shelf_widget.h" | 25 #include "ash/shelf/shelf_widget.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 std::string app_id_; | 301 std::string app_id_; |
303 | 302 |
304 DISALLOW_COPY_AND_ASSIGN(TestShelfDelegateForShelfView); | 303 DISALLOW_COPY_AND_ASSIGN(TestShelfDelegateForShelfView); |
305 }; | 304 }; |
306 | 305 |
307 class ShelfViewTest : public AshTestBase { | 306 class ShelfViewTest : public AshTestBase { |
308 public: | 307 public: |
309 static const char* | 308 static const char* |
310 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; | 309 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName; |
311 | 310 |
312 ShelfViewTest() | 311 ShelfViewTest() : model_(nullptr), shelf_view_(nullptr), browser_index_(1) {} |
313 : model_(NULL), | |
314 shelf_view_(NULL), | |
315 browser_index_(1), | |
316 item_manager_(NULL) {} | |
317 ~ShelfViewTest() override {} | 312 ~ShelfViewTest() override {} |
318 | 313 |
319 void SetUp() override { | 314 void SetUp() override { |
320 AshTestBase::SetUp(); | 315 AshTestBase::SetUp(); |
321 ShellTestApi test_api(Shell::GetInstance()); | 316 ShellTestApi test_api(Shell::GetInstance()); |
322 model_ = test_api.shelf_model(); | 317 model_ = test_api.shelf_model(); |
323 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 318 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
324 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); | 319 shelf_view_ = ShelfTestAPI(shelf).shelf_view(); |
325 | 320 |
326 // The bounds should be big enough for 4 buttons + overflow chevron. | 321 // The bounds should be big enough for 4 buttons + overflow chevron. |
327 shelf_view_->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE)); | 322 shelf_view_->SetBounds(0, 0, 500, GetShelfConstant(SHELF_SIZE)); |
328 | 323 |
329 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); | 324 test_api_.reset(new ShelfViewTestAPI(shelf_view_)); |
330 test_api_->SetAnimationDuration(1); // Speeds up animation for test. | 325 test_api_->SetAnimationDuration(1); // Speeds up animation for test. |
331 | 326 |
332 ReplaceShelfDelegate(); | 327 ReplaceShelfDelegate(); |
333 | 328 |
334 item_manager_ = Shell::GetInstance()->shelf_item_delegate_manager(); | |
335 DCHECK(item_manager_); | |
336 | |
337 // Add browser shortcut shelf item at index 0 for test. | 329 // Add browser shortcut shelf item at index 0 for test. |
338 AddBrowserShortcut(); | 330 AddBrowserShortcut(); |
339 } | 331 } |
340 | 332 |
341 void TearDown() override { | 333 void TearDown() override { |
342 shelf_delegate_ = nullptr; | 334 shelf_delegate_ = nullptr; |
343 test_api_.reset(); | 335 test_api_.reset(); |
344 AshTestBase::TearDown(); | 336 AshTestBase::TearDown(); |
345 } | 337 } |
346 | 338 |
347 protected: | 339 protected: |
348 void CreateAndSetShelfItemDelegateForID(ShelfID id) { | 340 void CreateAndSetShelfItemDelegateForID(ShelfID id) { |
349 std::unique_ptr<ShelfItemDelegate> delegate( | 341 std::unique_ptr<ShelfItemDelegate> delegate( |
350 new TestShelfItemDelegate(NULL)); | 342 new TestShelfItemDelegate(NULL)); |
351 item_manager_->SetShelfItemDelegate(id, std::move(delegate)); | 343 model_->SetShelfItemDelegate(id, std::move(delegate)); |
352 } | 344 } |
353 | 345 |
354 ShelfID AddBrowserShortcut() { | 346 ShelfID AddBrowserShortcut() { |
355 ShelfItem browser_shortcut; | 347 ShelfItem browser_shortcut; |
356 browser_shortcut.type = TYPE_BROWSER_SHORTCUT; | 348 browser_shortcut.type = TYPE_BROWSER_SHORTCUT; |
357 | 349 |
358 ShelfID id = model_->next_id(); | 350 ShelfID id = model_->next_id(); |
359 model_->AddAt(browser_index_, browser_shortcut); | 351 model_->AddAt(browser_index_, browser_shortcut); |
360 CreateAndSetShelfItemDelegateForID(id); | 352 CreateAndSetShelfItemDelegateForID(id); |
361 test_api_->RunMessageLoopUntilAnimationsDone(); | 353 test_api_->RunMessageLoopUntilAnimationsDone(); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 shell_test_api.SetShelfDelegate(NULL); | 690 shell_test_api.SetShelfDelegate(NULL); |
699 shelf_delegate_ = new TestShelfDelegateForShelfView(); | 691 shelf_delegate_ = new TestShelfDelegateForShelfView(); |
700 shell_test_api.SetShelfDelegate(shelf_delegate_); | 692 shell_test_api.SetShelfDelegate(shelf_delegate_); |
701 ShelfTestAPI(Shelf::ForPrimaryDisplay()).set_delegate(shelf_delegate_); | 693 ShelfTestAPI(Shelf::ForPrimaryDisplay()).set_delegate(shelf_delegate_); |
702 test_api_->SetShelfDelegate(shelf_delegate_); | 694 test_api_->SetShelfDelegate(shelf_delegate_); |
703 } | 695 } |
704 | 696 |
705 ShelfModel* model_; | 697 ShelfModel* model_; |
706 ShelfView* shelf_view_; | 698 ShelfView* shelf_view_; |
707 int browser_index_; | 699 int browser_index_; |
708 ShelfItemDelegateManager* item_manager_; | |
709 | 700 |
710 // Owned by ash::Shell. | 701 // Owned by ash::Shell. |
711 TestShelfDelegateForShelfView* shelf_delegate_; | 702 TestShelfDelegateForShelfView* shelf_delegate_; |
712 | 703 |
713 std::unique_ptr<ShelfViewTestAPI> test_api_; | 704 std::unique_ptr<ShelfViewTestAPI> test_api_; |
714 | 705 |
715 private: | 706 private: |
716 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); | 707 DISALLOW_COPY_AND_ASSIGN(ShelfViewTest); |
717 }; | 708 }; |
718 | 709 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1194 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1204 } | 1195 } |
1205 | 1196 |
1206 // Check that whether the ash behaves correctly if not draggable | 1197 // Check that whether the ash behaves correctly if not draggable |
1207 // item are in front of the shelf. | 1198 // item are in front of the shelf. |
1208 TEST_F(ShelfViewTest, DragWithNotDraggableItemInFront) { | 1199 TEST_F(ShelfViewTest, DragWithNotDraggableItemInFront) { |
1209 std::vector<std::pair<ShelfID, views::View*>> id_map; | 1200 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1210 SetupForDragTest(&id_map); | 1201 SetupForDragTest(&id_map); |
1211 | 1202 |
1212 (static_cast<TestShelfItemDelegate*>( | 1203 (static_cast<TestShelfItemDelegate*>( |
1213 item_manager_->GetShelfItemDelegate(id_map[1].first))) | 1204 model_->GetShelfItemDelegate(id_map[1].first))) |
1214 ->set_is_draggable(false); | 1205 ->set_is_draggable(false); |
1215 (static_cast<TestShelfItemDelegate*>( | 1206 (static_cast<TestShelfItemDelegate*>( |
1216 item_manager_->GetShelfItemDelegate(id_map[2].first))) | 1207 model_->GetShelfItemDelegate(id_map[2].first))) |
1217 ->set_is_draggable(false); | 1208 ->set_is_draggable(false); |
1218 | 1209 |
1219 ASSERT_NO_FATAL_FAILURE(DragAndVerify(3, 1, shelf_view_, id_map)); | 1210 ASSERT_NO_FATAL_FAILURE(DragAndVerify(3, 1, shelf_view_, id_map)); |
1220 ASSERT_NO_FATAL_FAILURE(DragAndVerify(3, 2, shelf_view_, id_map)); | 1211 ASSERT_NO_FATAL_FAILURE(DragAndVerify(3, 2, shelf_view_, id_map)); |
1221 | 1212 |
1222 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); | 1213 std::rotate(id_map.begin() + 3, id_map.begin() + 4, id_map.begin() + 5); |
1223 ASSERT_NO_FATAL_FAILURE(DragAndVerify(4, 1, shelf_view_, id_map)); | 1214 ASSERT_NO_FATAL_FAILURE(DragAndVerify(4, 1, shelf_view_, id_map)); |
1224 std::rotate(id_map.begin() + 3, id_map.begin() + 5, id_map.begin() + 6); | 1215 std::rotate(id_map.begin() + 3, id_map.begin() + 5, id_map.begin() + 6); |
1225 ASSERT_NO_FATAL_FAILURE(DragAndVerify(5, 1, shelf_view_, id_map)); | 1216 ASSERT_NO_FATAL_FAILURE(DragAndVerify(5, 1, shelf_view_, id_map)); |
1226 } | 1217 } |
(...skipping 14 matching lines...) Expand all Loading... |
1241 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); | 1232 ASSERT_NO_FATAL_FAILURE(CheckModelIDs(id_map)); |
1242 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); | 1233 shelf_view_->PointerReleasedOnButton(dragged_button, ShelfView::MOUSE, false); |
1243 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT); | 1234 EXPECT_TRUE(model_->items()[3].type == TYPE_BROWSER_SHORTCUT); |
1244 } | 1235 } |
1245 | 1236 |
1246 // Tests that double-clicking an item does not activate it twice. | 1237 // Tests that double-clicking an item does not activate it twice. |
1247 TEST_F(ShelfViewTest, ClickingTwiceActivatesOnce) { | 1238 TEST_F(ShelfViewTest, ClickingTwiceActivatesOnce) { |
1248 // Watch for selection of the browser shortcut. | 1239 // Watch for selection of the browser shortcut. |
1249 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1240 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1250 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1241 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1251 item_manager_->SetShelfItemDelegate( | 1242 model_->SetShelfItemDelegate( |
1252 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1243 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
1253 | 1244 |
1254 // A single click selects the item. | 1245 // A single click selects the item. |
1255 SimulateClick(browser_index_); | 1246 SimulateClick(browser_index_); |
1256 EXPECT_TRUE(selection_tracker->WasSelected()); | 1247 EXPECT_TRUE(selection_tracker->WasSelected()); |
1257 | 1248 |
1258 // A double-click does not select the item. | 1249 // A double-click does not select the item. |
1259 selection_tracker->Reset(); | 1250 selection_tracker->Reset(); |
1260 SimulateDoubleClick(browser_index_); | 1251 SimulateDoubleClick(browser_index_); |
1261 EXPECT_FALSE(selection_tracker->WasSelected()); | 1252 EXPECT_FALSE(selection_tracker->WasSelected()); |
1262 } | 1253 } |
1263 | 1254 |
1264 // Check that clicking an item and jittering the mouse a bit still selects the | 1255 // Check that clicking an item and jittering the mouse a bit still selects the |
1265 // item. | 1256 // item. |
1266 TEST_F(ShelfViewTest, ClickAndMoveSlightly) { | 1257 TEST_F(ShelfViewTest, ClickAndMoveSlightly) { |
1267 std::vector<std::pair<ShelfID, views::View*>> id_map; | 1258 std::vector<std::pair<ShelfID, views::View*>> id_map; |
1268 SetupForDragTest(&id_map); | 1259 SetupForDragTest(&id_map); |
1269 | 1260 |
1270 ShelfID shelf_id = (id_map.begin() + 1)->first; | 1261 ShelfID shelf_id = (id_map.begin() + 1)->first; |
1271 views::View* button = (id_map.begin() + 1)->second; | 1262 views::View* button = (id_map.begin() + 1)->second; |
1272 | 1263 |
1273 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether | 1264 // Replace the ShelfItemDelegate for |shelf_id| with one which tracks whether |
1274 // the shelf item gets selected. | 1265 // the shelf item gets selected. |
1275 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1266 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1276 item_manager_->SetShelfItemDelegate( | 1267 model_->SetShelfItemDelegate( |
1277 shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1268 shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
1278 | 1269 |
1279 gfx::Vector2d press_offset(5, 30); | 1270 gfx::Vector2d press_offset(5, 30); |
1280 gfx::Point press_location = gfx::Point() + press_offset; | 1271 gfx::Point press_location = gfx::Point() + press_offset; |
1281 gfx::Point press_location_in_screen = | 1272 gfx::Point press_location_in_screen = |
1282 button->GetBoundsInScreen().origin() + press_offset; | 1273 button->GetBoundsInScreen().origin() + press_offset; |
1283 | 1274 |
1284 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, press_location, | 1275 ui::MouseEvent click_event(ui::ET_MOUSE_PRESSED, press_location, |
1285 press_location_in_screen, ui::EventTimeForNow(), | 1276 press_location_in_screen, ui::EventTimeForNow(), |
1286 ui::EF_LEFT_MOUSE_BUTTON, 0); | 1277 ui::EF_LEFT_MOUSE_BUTTON, 0); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 } | 1865 } |
1875 | 1866 |
1876 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an | 1867 // Verifies that Launcher_ButtonPressed_* UMA user actions are recorded when an |
1877 // item is selected. | 1868 // item is selected. |
1878 TEST_F(ShelfViewTest, | 1869 TEST_F(ShelfViewTest, |
1879 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { | 1870 Launcher_ButtonPressedUserActionsRecordedWhenItemSelected) { |
1880 base::UserActionTester user_action_tester; | 1871 base::UserActionTester user_action_tester; |
1881 | 1872 |
1882 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1873 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1883 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1874 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1884 item_manager_->SetShelfItemDelegate( | 1875 model_->SetShelfItemDelegate( |
1885 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1876 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
1886 | 1877 |
1887 SimulateClick(browser_index_); | 1878 SimulateClick(browser_index_); |
1888 EXPECT_EQ(1, | 1879 EXPECT_EQ(1, |
1889 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); | 1880 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); |
1890 } | 1881 } |
1891 | 1882 |
1892 // Verifies that Launcher_*Task UMA user actions are recorded when an item is | 1883 // Verifies that Launcher_*Task UMA user actions are recorded when an item is |
1893 // selected. | 1884 // selected. |
1894 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { | 1885 TEST_F(ShelfViewTest, Launcher_TaskUserActionsRecordedWhenItemSelected) { |
1895 base::UserActionTester user_action_tester; | 1886 base::UserActionTester user_action_tester; |
1896 | 1887 |
1897 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1888 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1898 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1889 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1899 selection_tracker->set_item_selected_action( | 1890 selection_tracker->set_item_selected_action( |
1900 ShelfItemDelegate::kNewWindowCreated); | 1891 ShelfItemDelegate::kNewWindowCreated); |
1901 item_manager_->SetShelfItemDelegate( | 1892 model_->SetShelfItemDelegate( |
1902 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1893 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
1903 | 1894 |
1904 SimulateClick(browser_index_); | 1895 SimulateClick(browser_index_); |
1905 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); | 1896 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); |
1906 } | 1897 } |
1907 | 1898 |
1908 // Verifies that metrics are recorded when an item is minimized and subsequently | 1899 // Verifies that metrics are recorded when an item is minimized and subsequently |
1909 // activated. | 1900 // activated. |
1910 TEST_F(ShelfViewTest, | 1901 TEST_F(ShelfViewTest, |
1911 VerifyMetricsAreRecordedWhenAnItemIsMinimizedAndActivated) { | 1902 VerifyMetricsAreRecordedWhenAnItemIsMinimizedAndActivated) { |
1912 base::HistogramTester histogram_tester; | 1903 base::HistogramTester histogram_tester; |
1913 | 1904 |
1914 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 1905 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
1915 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; | 1906 ShelfItemSelectionTracker* selection_tracker = new ShelfItemSelectionTracker; |
1916 item_manager_->SetShelfItemDelegate( | 1907 model_->SetShelfItemDelegate( |
1917 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); | 1908 browser_shelf_id, std::unique_ptr<ShelfItemDelegate>(selection_tracker)); |
1918 | 1909 |
1919 selection_tracker->set_item_selected_action( | 1910 selection_tracker->set_item_selected_action( |
1920 ShelfItemDelegate::kExistingWindowMinimized); | 1911 ShelfItemDelegate::kExistingWindowMinimized); |
1921 SimulateClick(browser_index_); | 1912 SimulateClick(browser_index_); |
1922 | 1913 |
1923 selection_tracker->set_item_selected_action( | 1914 selection_tracker->set_item_selected_action( |
1924 ShelfItemDelegate::kExistingWindowActivated); | 1915 ShelfItemDelegate::kExistingWindowActivated); |
1925 SimulateClick(browser_index_); | 1916 SimulateClick(browser_index_); |
1926 | 1917 |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 } | 2553 } |
2563 | 2554 |
2564 // Tests that clicking on a shelf item that shows an app list menu transitions | 2555 // Tests that clicking on a shelf item that shows an app list menu transitions |
2565 // ink drop state correctly. | 2556 // ink drop state correctly. |
2566 TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) { | 2557 TEST_F(ShelfViewInkDropTest, ShelfButtonWithMenuPressRelease) { |
2567 InitBrowserButtonInkDrop(); | 2558 InitBrowserButtonInkDrop(); |
2568 | 2559 |
2569 // Set a delegate for the shelf item that returns an app list menu. | 2560 // Set a delegate for the shelf item that returns an app list menu. |
2570 ShelfID browser_shelf_id = model_->items()[browser_index_].id; | 2561 ShelfID browser_shelf_id = model_->items()[browser_index_].id; |
2571 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; | 2562 ListMenuShelfItemDelegate* list_menu_delegate = new ListMenuShelfItemDelegate; |
2572 item_manager_->SetShelfItemDelegate(browser_shelf_id, | 2563 model_->SetShelfItemDelegate(browser_shelf_id, |
2573 base::WrapUnique(list_menu_delegate)); | 2564 base::WrapUnique(list_menu_delegate)); |
2574 | 2565 |
2575 views::CustomButton* button = browser_button_; | 2566 views::CustomButton* button = browser_button_; |
2576 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); | 2567 gfx::Point mouse_location = button->GetLocalBounds().CenterPoint(); |
2577 | 2568 |
2578 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, | 2569 ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, mouse_location, |
2579 mouse_location, ui::EventTimeForNow(), | 2570 mouse_location, ui::EventTimeForNow(), |
2580 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2571 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2581 button->OnMousePressed(press_event); | 2572 button->OnMousePressed(press_event); |
2582 EXPECT_EQ(views::InkDropState::ACTION_PENDING, | 2573 EXPECT_EQ(views::InkDropState::ACTION_PENDING, |
2583 browser_button_ink_drop_->GetTargetInkDropState()); | 2574 browser_button_ink_drop_->GetTargetInkDropState()); |
2584 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2575 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2585 ElementsAre(views::InkDropState::ACTION_PENDING)); | 2576 ElementsAre(views::InkDropState::ACTION_PENDING)); |
2586 | 2577 |
2587 // Mouse release will spawn a menu which we will then close. | 2578 // Mouse release will spawn a menu which we will then close. |
2588 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, | 2579 ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, mouse_location, |
2589 mouse_location, ui::EventTimeForNow(), | 2580 mouse_location, ui::EventTimeForNow(), |
2590 ui::EF_LEFT_MOUSE_BUTTON, 0); | 2581 ui::EF_LEFT_MOUSE_BUTTON, 0); |
2591 button->OnMouseReleased(release_event); | 2582 button->OnMouseReleased(release_event); |
2592 test_api_->CloseMenu(); | 2583 test_api_->CloseMenu(); |
2593 EXPECT_EQ(views::InkDropState::HIDDEN, | 2584 EXPECT_EQ(views::InkDropState::HIDDEN, |
2594 browser_button_ink_drop_->GetTargetInkDropState()); | 2585 browser_button_ink_drop_->GetTargetInkDropState()); |
2595 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2586 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2596 ElementsAre(views::InkDropState::ACTIVATED, | 2587 ElementsAre(views::InkDropState::ACTIVATED, |
2597 views::InkDropState::DEACTIVATED)); | 2588 views::InkDropState::DEACTIVATED)); |
2598 } | 2589 } |
2599 | 2590 |
2600 } // namespace test | 2591 } // namespace test |
2601 } // namespace ash | 2592 } // namespace ash |
OLD | NEW |