| 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::ViewModel* view_model = grid_view->view_model_for_test(); | 105 const views::ViewModel* view_model = grid_view->view_model_for_test(); |
| 103 for (int i = 0; i < view_model->view_size(); ++i) { | 106 for (int i = 0; i < view_model->view_size(); ++i) { |
| 104 views::View* view = view_model->view_at(i); | 107 views::View* view = view_model->view_at(i); |
| 105 if (view->bounds().Contains(point)) { | 108 if (view->bounds().Contains(point)) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 EXPECT_TRUE(RootGridView()->visible()); | 224 EXPECT_TRUE(RootGridView()->visible()); |
| 222 EXPECT_EQ(0, FolderView()->layer()->opacity()); | 225 EXPECT_EQ(0, FolderView()->layer()->opacity()); |
| 223 | 226 |
| 224 return dragged; | 227 return dragged; |
| 225 } | 228 } |
| 226 | 229 |
| 227 protected: | 230 protected: |
| 228 views::Widget* widget_; // Owned by native window. | 231 views::Widget* widget_; // Owned by native window. |
| 229 AppListMainView* main_view_; // Owned by |widget_|. | 232 AppListMainView* main_view_; // Owned by |widget_|. |
| 230 scoped_ptr<AppListTestViewDelegate> delegate_; | 233 scoped_ptr<AppListTestViewDelegate> delegate_; |
| 234 scoped_ptr<SearchBoxView> search_box_view_; |
| 231 | 235 |
| 232 private: | 236 private: |
| 233 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); | 237 DISALLOW_COPY_AND_ASSIGN(AppListMainViewTest); |
| 234 }; | 238 }; |
| 235 | 239 |
| 236 } // namespace | 240 } // namespace |
| 237 | 241 |
| 238 // Tests changing the AppListModel when switching profiles. | 242 // Tests changing the AppListModel when switching profiles. |
| 239 TEST_F(AppListMainViewTest, ModelChanged) { | 243 TEST_F(AppListMainViewTest, ModelChanged) { |
| 240 delegate_->GetTestModel()->PopulateApps(kInitialItems); | 244 delegate_->GetTestModel()->PopulateApps(kInitialItems); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 335 |
| 332 // Additional mouse move operations should be ignored. | 336 // Additional mouse move operations should be ignored. |
| 333 gfx::Point point(1, 1); | 337 gfx::Point point(1, 1); |
| 334 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); | 338 SimulateUpdateDrag(FolderGridView(), AppsGridView::MOUSE, dragged, point); |
| 335 EXPECT_FALSE(RootGridView()->has_dragged_view()); | 339 EXPECT_FALSE(RootGridView()->has_dragged_view()); |
| 336 EXPECT_FALSE(FolderGridView()->has_dragged_view()); | 340 EXPECT_FALSE(FolderGridView()->has_dragged_view()); |
| 337 } | 341 } |
| 338 | 342 |
| 339 } // namespace test | 343 } // namespace test |
| 340 } // namespace app_list | 344 } // namespace app_list |
| OLD | NEW |