| 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 <memory> |
| 8 |
| 7 #include "base/macros.h" | 9 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 10 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 11 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/app_list/app_list_switches.h" | 15 #include "ui/app_list/app_list_switches.h" |
| 15 #include "ui/app_list/test/app_list_test_model.h" | 16 #include "ui/app_list/test/app_list_test_model.h" |
| 16 #include "ui/app_list/test/app_list_test_view_delegate.h" | 17 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 17 #include "ui/app_list/views/app_list_folder_view.h" | 18 #include "ui/app_list/views/app_list_folder_view.h" |
| 18 #include "ui/app_list/views/app_list_item_view.h" | 19 #include "ui/app_list/views/app_list_item_view.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 check_timer_.Stop(); | 54 check_timer_.Stop(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 void OnTimerCheck() { | 58 void OnTimerCheck() { |
| 58 if (grid_view_->visible()) | 59 if (grid_view_->visible()) |
| 59 run_loop_->Quit(); | 60 run_loop_->Quit(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 AppsGridView* grid_view_; | 63 AppsGridView* grid_view_; |
| 63 scoped_ptr<base::RunLoop> run_loop_; | 64 std::unique_ptr<base::RunLoop> run_loop_; |
| 64 base::RepeatingTimer check_timer_; | 65 base::RepeatingTimer check_timer_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(GridViewVisibleWaiter); | 67 DISALLOW_COPY_AND_ASSIGN(GridViewVisibleWaiter); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 class AppListMainViewTest : public views::ViewsTestBase { | 70 class AppListMainViewTest : public views::ViewsTestBase { |
| 70 public: | 71 public: |
| 71 AppListMainViewTest() | 72 AppListMainViewTest() |
| 72 : main_widget_(nullptr), | 73 : main_widget_(nullptr), |
| 73 main_view_(nullptr), | 74 main_view_(nullptr), |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 GridViewVisibleWaiter(RootGridView()).Wait(); | 237 GridViewVisibleWaiter(RootGridView()).Wait(); |
| 237 EXPECT_TRUE(RootGridView()->visible()); | 238 EXPECT_TRUE(RootGridView()->visible()); |
| 238 EXPECT_EQ(0, FolderView()->layer()->opacity()); | 239 EXPECT_EQ(0, FolderView()->layer()->opacity()); |
| 239 | 240 |
| 240 return dragged; | 241 return dragged; |
| 241 } | 242 } |
| 242 | 243 |
| 243 protected: | 244 protected: |
| 244 views::Widget* main_widget_; // Owned by native window. | 245 views::Widget* main_widget_; // Owned by native window. |
| 245 AppListMainView* main_view_; // Owned by |main_widget_|. | 246 AppListMainView* main_view_; // Owned by |main_widget_|. |
| 246 scoped_ptr<AppListTestViewDelegate> delegate_; | 247 std::unique_ptr<AppListTestViewDelegate> delegate_; |
| 247 views::Widget* search_box_widget_; // Owned by |main_widget_|. | 248 views::Widget* search_box_widget_; // Owned by |main_widget_|. |
| 248 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 249 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. |
| 249 | 250 |
| 250 private: | 251 private: |
| 251 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); | 252 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); |
| 252 }; | 253 }; |
| 253 | 254 |
| 254 } // namespace | 255 } // namespace |
| 255 | 256 |
| 256 // Tests changing the AppListModel when switching profiles. | 257 // Tests changing the AppListModel when switching profiles. |
| 257 TEST_F(AppListMainViewTest, ModelChanged) { | 258 TEST_F(AppListMainViewTest, ModelChanged) { |
| 258 delegate_->GetTestModel()->PopulateApps(kInitialItems); | 259 delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| 259 EXPECT_EQ(kInitialItems, RootViewModel()->view_size()); | 260 EXPECT_EQ(kInitialItems, RootViewModel()->view_size()); |
| 260 | 261 |
| 261 // The model is owned by a profile keyed service, which is never destroyed | 262 // The model is owned by a profile keyed service, which is never destroyed |
| 262 // until after profile switching. | 263 // until after profile switching. |
| 263 scoped_ptr<AppListModel> old_model(delegate_->ReleaseTestModel()); | 264 std::unique_ptr<AppListModel> old_model(delegate_->ReleaseTestModel()); |
| 264 | 265 |
| 265 const int kReplacementItems = 5; | 266 const int kReplacementItems = 5; |
| 266 delegate_->ReplaceTestModel(kReplacementItems); | 267 delegate_->ReplaceTestModel(kReplacementItems); |
| 267 main_view_->ModelChanged(); | 268 main_view_->ModelChanged(); |
| 268 EXPECT_EQ(kReplacementItems, RootViewModel()->view_size()); | 269 EXPECT_EQ(kReplacementItems, RootViewModel()->view_size()); |
| 269 } | 270 } |
| 270 | 271 |
| 271 // Tests that mouse hovering over an app item highlights it | 272 // Tests that mouse hovering over an app item highlights it |
| 272 TEST_F(AppListMainViewTest, MouseHoverToHighlight) { | 273 TEST_F(AppListMainViewTest, MouseHoverToHighlight) { |
| 273 delegate_->GetTestModel()->PopulateApps(2); | 274 delegate_->GetTestModel()->PopulateApps(2); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // The app list model should remain unchanged. | 457 // The app list model should remain unchanged. |
| 457 EXPECT_EQ(1, FolderViewModel()->view_size()); | 458 EXPECT_EQ(1, FolderViewModel()->view_size()); |
| 458 EXPECT_EQ(2, RootViewModel()->view_size()); | 459 EXPECT_EQ(2, RootViewModel()->view_size()); |
| 459 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); | 460 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); |
| 460 EXPECT_NE(nullptr, | 461 EXPECT_NE(nullptr, |
| 461 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 462 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 462 } | 463 } |
| 463 | 464 |
| 464 } // namespace test | 465 } // namespace test |
| 465 } // namespace app_list | 466 } // namespace app_list |
| OLD | NEW |