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/test/app_list_test_model.h" | 12 #include "ui/app_list/test/app_list_test_model.h" |
13 #include "ui/app_list/test/app_list_test_view_delegate.h" | 13 #include "ui/app_list/test/app_list_test_view_delegate.h" |
14 #include "ui/app_list/views/app_list_folder_view.h" | 14 #include "ui/app_list/views/app_list_folder_view.h" |
15 #include "ui/app_list/views/app_list_item_view.h" | 15 #include "ui/app_list/views/app_list_item_view.h" |
16 #include "ui/app_list/views/apps_container_view.h" | 16 #include "ui/app_list/views/apps_container_view.h" |
17 #include "ui/app_list/views/apps_grid_view.h" | 17 #include "ui/app_list/views/apps_grid_view.h" |
18 #include "ui/app_list/views/contents_view.h" | 18 #include "ui/app_list/views/contents_view.h" |
| 19 #include "ui/app_list/views/search_box_view.h" |
19 #include "ui/app_list/views/test/apps_grid_view_test_api.h" | 20 #include "ui/app_list/views/test/apps_grid_view_test_api.h" |
20 #include "ui/views/test/views_test_base.h" | 21 #include "ui/views/test/views_test_base.h" |
21 #include "ui/views/view_model.h" | 22 #include "ui/views/view_model.h" |
22 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
23 | 24 |
24 namespace app_list { | 25 namespace app_list { |
25 namespace test { | 26 namespace test { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 virtual void SetUp() override { | 73 virtual void SetUp() override { |
73 views::ViewsTestBase::SetUp(); | 74 views::ViewsTestBase::SetUp(); |
74 delegate_.reset(new AppListTestViewDelegate); | 75 delegate_.reset(new AppListTestViewDelegate); |
75 | 76 |
76 // In Ash, the third argument is a container aura::Window, but it is always | 77 // In Ash, the third argument is a container aura::Window, but it is always |
77 // NULL on Windows, and not needed for tests. It is only used to determine | 78 // NULL on Windows, and not needed for tests. It is only used to determine |
78 // the scale factor for preloading icons. | 79 // the scale factor for preloading icons. |
79 main_view_ = new AppListMainView(delegate_.get()); | 80 main_view_ = new AppListMainView(delegate_.get()); |
80 main_view_->SetPaintToLayer(true); | 81 main_view_->SetPaintToLayer(true); |
81 main_view_->model()->SetFoldersEnabled(true); | 82 main_view_->model()->SetFoldersEnabled(true); |
82 main_view_->Init(NULL, 0); | 83 search_box_view_.reset(new SearchBoxView(main_view_, delegate_.get())); |
| 84 main_view_->Init(NULL, 0, search_box_view_.get()); |
83 | 85 |
84 widget_ = new views::Widget; | 86 widget_ = new views::Widget; |
85 views::Widget::InitParams params = | 87 views::Widget::InitParams params = |
86 CreateParams(views::Widget::InitParams::TYPE_POPUP); | 88 CreateParams(views::Widget::InitParams::TYPE_POPUP); |
87 params.bounds.set_size(main_view_->GetPreferredSize()); | 89 params.bounds.set_size(main_view_->GetPreferredSize()); |
88 widget_->Init(params); | 90 widget_->Init(params); |
89 | 91 |
90 widget_->SetContentsView(main_view_); | 92 widget_->SetContentsView(main_view_); |
91 } | 93 } |
92 | 94 |
93 virtual void TearDown() override { | 95 virtual void TearDown() override { |
94 widget_->Close(); | 96 widget_->Close(); |
95 views::ViewsTestBase::TearDown(); | 97 views::ViewsTestBase::TearDown(); |
| 98 search_box_view_.reset(); |
96 delegate_.reset(); | 99 delegate_.reset(); |
97 } | 100 } |
98 | 101 |
99 // |point| is in |grid_view|'s coordinates. | 102 // |point| is in |grid_view|'s coordinates. |
100 AppListItemView* GetItemViewAtPointInGrid(AppsGridView* grid_view, | 103 AppListItemView* GetItemViewAtPointInGrid(AppsGridView* grid_view, |
101 const gfx::Point& point) { | 104 const gfx::Point& point) { |
102 const views::ViewModelT<AppListItemView>* view_model = | 105 const views::ViewModelT<AppListItemView>* view_model = |
103 grid_view->view_model_for_test(); | 106 grid_view->view_model_for_test(); |
104 for (int i = 0; i < view_model->view_size(); ++i) { | 107 for (int i = 0; i < view_model->view_size(); ++i) { |
105 views::View* view = view_model->view_at(i); | 108 views::View* view = view_model->view_at(i); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 EXPECT_TRUE(RootGridView()->visible()); | 225 EXPECT_TRUE(RootGridView()->visible()); |
223 EXPECT_EQ(0, FolderView()->layer()->opacity()); | 226 EXPECT_EQ(0, FolderView()->layer()->opacity()); |
224 | 227 |
225 return dragged; | 228 return dragged; |
226 } | 229 } |
227 | 230 |
228 protected: | 231 protected: |
229 views::Widget* widget_; // Owned by native window. | 232 views::Widget* widget_; // Owned by native window. |
230 AppListMainView* main_view_; // Owned by |widget_|. | 233 AppListMainView* main_view_; // Owned by |widget_|. |
231 scoped_ptr<AppListTestViewDelegate> delegate_; | 234 scoped_ptr<AppListTestViewDelegate> delegate_; |
| 235 scoped_ptr<SearchBoxView> search_box_view_; |
232 | 236 |
233 private: | 237 private: |
234 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); | 238 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); |
235 }; | 239 }; |
236 | 240 |
237 } // namespace | 241 } // namespace |
238 | 242 |
239 // Tests changing the AppListModel when switching profiles. | 243 // Tests changing the AppListModel when switching profiles. |
240 TEST_F(AppListMainViewTest, ModelChanged) { | 244 TEST_F(AppListMainViewTest, ModelChanged) { |
241 delegate_->GetTestModel()->PopulateApps(kInitialItems); | 245 delegate_->GetTestModel()->PopulateApps(kInitialItems); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 337 |
334 // Additional mouse move operations should be ignored. | 338 // Additional mouse move operations should be ignored. |
335 gfx::Point point(1, 1); | 339 gfx::Point point(1, 1); |
336 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); | 340 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); |
337 EXPECT_FALSE(RootGridView()->has_dragged_view()); | 341 EXPECT_FALSE(RootGridView()->has_dragged_view()); |
338 EXPECT_FALSE(FolderGridView()->has_dragged_view()); | 342 EXPECT_FALSE(FolderGridView()->has_dragged_view()); |
339 } | 343 } |
340 | 344 |
341 } // namespace test | 345 } // namespace test |
342 } // namespace app_list | 346 } // namespace app_list |
OLD | NEW |