| 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" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/app_list/pagination_model.h" | |
| 13 #include "ui/app_list/test/app_list_test_model.h" | 12 #include "ui/app_list/test/app_list_test_model.h" |
| 14 #include "ui/app_list/test/app_list_test_view_delegate.h" | 13 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 15 #include "ui/app_list/views/app_list_folder_view.h" | 14 #include "ui/app_list/views/app_list_folder_view.h" |
| 16 #include "ui/app_list/views/app_list_item_view.h" | 15 #include "ui/app_list/views/app_list_item_view.h" |
| 17 #include "ui/app_list/views/apps_container_view.h" | 16 #include "ui/app_list/views/apps_container_view.h" |
| 18 #include "ui/app_list/views/apps_grid_view.h" | 17 #include "ui/app_list/views/apps_grid_view.h" |
| 19 #include "ui/app_list/views/contents_view.h" | 18 #include "ui/app_list/views/contents_view.h" |
| 20 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 19 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
| 21 #include "ui/views/test/views_test_base.h" | 20 #include "ui/views/test/views_test_base.h" |
| 22 #include "ui/views/view_model.h" | 21 #include "ui/views/view_model.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 : widget_(NULL), | 66 : widget_(NULL), |
| 68 main_view_(NULL) {} | 67 main_view_(NULL) {} |
| 69 | 68 |
| 70 virtual ~AppListMainViewTest() {} | 69 virtual ~AppListMainViewTest() {} |
| 71 | 70 |
| 72 // testing::Test overrides: | 71 // testing::Test overrides: |
| 73 virtual void SetUp() OVERRIDE { | 72 virtual void SetUp() OVERRIDE { |
| 74 views::ViewsTestBase::SetUp(); | 73 views::ViewsTestBase::SetUp(); |
| 75 delegate_.reset(new AppListTestViewDelegate); | 74 delegate_.reset(new AppListTestViewDelegate); |
| 76 | 75 |
| 77 main_view_ = | 76 main_view_ = new AppListMainView(delegate_.get(), GetContext()); |
| 78 new AppListMainView(delegate_.get(), &pagination_model_, GetContext()); | |
| 79 main_view_->SetPaintToLayer(true); | 77 main_view_->SetPaintToLayer(true); |
| 80 | 78 |
| 81 widget_ = new views::Widget; | 79 widget_ = new views::Widget; |
| 82 views::Widget::InitParams params = | 80 views::Widget::InitParams params = |
| 83 CreateParams(views::Widget::InitParams::TYPE_POPUP); | 81 CreateParams(views::Widget::InitParams::TYPE_POPUP); |
| 84 params.bounds.set_size(main_view_->GetPreferredSize()); | 82 params.bounds.set_size(main_view_->GetPreferredSize()); |
| 85 widget_->Init(params); | 83 widget_->Init(params); |
| 86 | 84 |
| 87 widget_->SetContentsView(main_view_); | 85 widget_->SetContentsView(main_view_); |
| 88 } | 86 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return RootGridView()->view_model_for_test(); | 161 return RootGridView()->view_model_for_test(); |
| 164 } | 162 } |
| 165 | 163 |
| 166 const views::ViewModel* FolderViewModel() { | 164 const views::ViewModel* FolderViewModel() { |
| 167 return FolderGridView()->view_model_for_test(); | 165 return FolderGridView()->view_model_for_test(); |
| 168 } | 166 } |
| 169 | 167 |
| 170 protected: | 168 protected: |
| 171 views::Widget* widget_; // Owned by native window. | 169 views::Widget* widget_; // Owned by native window. |
| 172 AppListMainView* main_view_; // Owned by |widget_|. | 170 AppListMainView* main_view_; // Owned by |widget_|. |
| 173 PaginationModel pagination_model_; | |
| 174 scoped_ptr<AppListTestViewDelegate> delegate_; | 171 scoped_ptr<AppListTestViewDelegate> delegate_; |
| 175 | 172 |
| 176 private: | 173 private: |
| 177 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); | 174 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); |
| 178 }; | 175 }; |
| 179 | 176 |
| 180 } // namespace | 177 } // namespace |
| 181 | 178 |
| 182 // Tests changing the AppListModel when switching profiles. | 179 // Tests changing the AppListModel when switching profiles. |
| 183 TEST_F(AppListMainViewTest, ModelChanged) { | 180 TEST_F(AppListMainViewTest, ModelChanged) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 root_grid_view_test_api.LayoutToIdealBounds(); | 265 root_grid_view_test_api.LayoutToIdealBounds(); |
| 269 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); | 266 EXPECT_EQ(first_slot_tile, RootViewModel()->view_at(0)->bounds()); |
| 270 | 267 |
| 271 // Single item folder should be auto removed. | 268 // Single item folder should be auto removed. |
| 272 EXPECT_EQ(NULL, | 269 EXPECT_EQ(NULL, |
| 273 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); | 270 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); |
| 274 } | 271 } |
| 275 | 272 |
| 276 } // namespace test | 273 } // namespace test |
| 277 } // namespace app_list | 274 } // namespace app_list |
| OLD | NEW |