| 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 "ui/app_list/views/app_list_main_view.h" | 5 #include "ui/app_list/views/app_list_main_view.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 delegate_->ReplaceTestModel(kReplacementItems); | 266 delegate_->ReplaceTestModel(kReplacementItems); |
| 267 main_view_->ModelChanged(); | 267 main_view_->ModelChanged(); |
| 268 EXPECT_EQ(kReplacementItems, RootViewModel()->view_size()); | 268 EXPECT_EQ(kReplacementItems, RootViewModel()->view_size()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Tests that mouse hovering over an app item highlights it | 271 // Tests that mouse hovering over an app item highlights it |
| 272 TEST_F(AppListMainViewTest, MouseHoverToHighlight) { | 272 TEST_F(AppListMainViewTest, MouseHoverToHighlight) { |
| 273 delegate_->GetTestModel()->PopulateApps(2); | 273 delegate_->GetTestModel()->PopulateApps(2); |
| 274 main_widget_->Show(); | 274 main_widget_->Show(); |
| 275 | 275 |
| 276 ui::test::EventGenerator generator( | 276 ui::test::EventGenerator generator(GetContext(), |
| 277 main_widget_->GetNativeWindow()->GetRootWindow()); | 277 main_widget_->GetNativeWindow()); |
| 278 AppListItemView* item0 = RootViewModel()->view_at(0); | 278 AppListItemView* item0 = RootViewModel()->view_at(0); |
| 279 AppListItemView* item1 = RootViewModel()->view_at(1); | 279 AppListItemView* item1 = RootViewModel()->view_at(1); |
| 280 | 280 |
| 281 // If experimental launcher, switch to All Apps page | 281 // If experimental launcher, switch to All Apps page |
| 282 if (app_list::switches::IsExperimentalAppListEnabled()) { | 282 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 283 GetContentsView()->SetActivePage( | 283 GetContentsView()->SetActivePage( |
| 284 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS)); | 284 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS)); |
| 285 GetContentsView()->Layout(); | 285 GetContentsView()->Layout(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 generator.MoveMouseTo(item0->GetBoundsInScreen().CenterPoint()); | 288 generator.MoveMouseTo(item0->GetBoundsInScreen().CenterPoint()); |
| 289 EXPECT_TRUE(item0->is_highlighted()); | 289 EXPECT_TRUE(item0->is_highlighted()); |
| 290 EXPECT_FALSE(item1->is_highlighted()); | 290 EXPECT_FALSE(item1->is_highlighted()); |
| 291 | 291 |
| 292 generator.MoveMouseTo(item1->GetBoundsInScreen().CenterPoint()); | 292 generator.MoveMouseTo(item1->GetBoundsInScreen().CenterPoint()); |
| 293 EXPECT_FALSE(item0->is_highlighted()); | 293 EXPECT_FALSE(item0->is_highlighted()); |
| 294 EXPECT_TRUE(item1->is_highlighted()); | 294 EXPECT_TRUE(item1->is_highlighted()); |
| 295 | 295 |
| 296 generator.MoveMouseTo(gfx::Point(-1, -1)); | 296 generator.MoveMouseTo(gfx::Point(-1, -1)); |
| 297 EXPECT_FALSE(item0->is_highlighted()); | 297 EXPECT_FALSE(item0->is_highlighted()); |
| 298 EXPECT_FALSE(item1->is_highlighted()); | 298 EXPECT_FALSE(item1->is_highlighted()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // No touch on desktop Mac. Tracked in http://crbug.com/445520. |
| 302 #if defined(OS_MACOSX) && !defined(USE_AURA) |
| 303 #define MAYBE_TapGestureToHighlight DISABLED_TapGestureToHighlight |
| 304 #else |
| 305 #define MAYBE_TapGestureToHighlight TapGestureToHighlight |
| 306 #endif |
| 307 |
| 301 // Tests that tap gesture on app item highlights it | 308 // Tests that tap gesture on app item highlights it |
| 302 TEST_F(AppListMainViewTest, TapGestureToHighlight) { | 309 TEST_F(AppListMainViewTest, MAYBE_TapGestureToHighlight) { |
| 303 delegate_->GetTestModel()->PopulateApps(1); | 310 delegate_->GetTestModel()->PopulateApps(1); |
| 304 main_widget_->Show(); | 311 main_widget_->Show(); |
| 305 | 312 |
| 306 ui::test::EventGenerator generator( | 313 ui::test::EventGenerator generator(GetContext(), |
| 307 main_widget_->GetNativeWindow()->GetRootWindow()); | 314 main_widget_->GetNativeWindow()); |
| 308 AppListItemView* item = RootViewModel()->view_at(0); | 315 AppListItemView* item = RootViewModel()->view_at(0); |
| 309 | 316 |
| 310 // If experimental launcher, switch to All Apps page | 317 // If experimental launcher, switch to All Apps page |
| 311 if (app_list::switches::IsExperimentalAppListEnabled()) { | 318 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 312 GetContentsView()->SetActivePage( | 319 GetContentsView()->SetActivePage( |
| 313 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS)); | 320 GetContentsView()->GetPageIndexForState(AppListModel::STATE_APPS)); |
| 314 GetContentsView()->Layout(); | 321 GetContentsView()->Layout(); |
| 315 } | 322 } |
| 316 | 323 |
| 317 generator.set_current_location(item->GetBoundsInScreen().CenterPoint()); | 324 generator.set_current_location(item->GetBoundsInScreen().CenterPoint()); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // The app list model should remain unchanged. | 451 // The app list model should remain unchanged. |
| 445 EXPECT_EQ(1, FolderViewModel()->view_size()); | 452 EXPECT_EQ(1, FolderViewModel()->view_size()); |
| 446 EXPECT_EQ(2, RootViewModel()->view_size()); | 453 EXPECT_EQ(2, RootViewModel()->view_size()); |
| 447 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); | 454 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); |
| 448 EXPECT_NE(nullptr, | 455 EXPECT_NE(nullptr, |
| 449 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 456 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 450 } | 457 } |
| 451 | 458 |
| 452 } // namespace test | 459 } // namespace test |
| 453 } // namespace app_list | 460 } // namespace app_list |
| OLD | NEW |