| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/app_list/app_list_constants.h" | 20 #include "ui/app_list/app_list_constants.h" |
| 20 #include "ui/app_list/app_list_switches.h" | 21 #include "ui/app_list/app_list_switches.h" |
| 21 #include "ui/app_list/pagination_model.h" | 22 #include "ui/app_list/pagination_model.h" |
| 22 #include "ui/app_list/search_box_model.h" | 23 #include "ui/app_list/search_box_model.h" |
| 23 #include "ui/app_list/test/app_list_test_model.h" | 24 #include "ui/app_list/test/app_list_test_model.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 void Close(); | 152 void Close(); |
| 152 | 153 |
| 153 // Checks the search box widget is at |expected| in the contents view's | 154 // Checks the search box widget is at |expected| in the contents view's |
| 154 // coordinate space. | 155 // coordinate space. |
| 155 bool CheckSearchBoxWidget(const gfx::Rect& expected); | 156 bool CheckSearchBoxWidget(const gfx::Rect& expected); |
| 156 | 157 |
| 157 // Gets the PaginationModel owned by |view_|. | 158 // Gets the PaginationModel owned by |view_|. |
| 158 PaginationModel* GetPaginationModel(); | 159 PaginationModel* GetPaginationModel(); |
| 159 | 160 |
| 160 const TestType test_type_; | 161 const TestType test_type_; |
| 161 scoped_ptr<base::RunLoop> run_loop_; | 162 std::unique_ptr<base::RunLoop> run_loop_; |
| 162 app_list::AppListView* view_; // Owned by native widget. | 163 app_list::AppListView* view_; // Owned by native widget. |
| 163 scoped_ptr<app_list::test::AppListTestViewDelegate> delegate_; | 164 std::unique_ptr<app_list::test::AppListTestViewDelegate> delegate_; |
| 164 | 165 |
| 165 DISALLOW_COPY_AND_ASSIGN(AppListViewTestContext); | 166 DISALLOW_COPY_AND_ASSIGN(AppListViewTestContext); |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 // Extend the regular AppListTestViewDelegate to communicate back to the test | 169 // Extend the regular AppListTestViewDelegate to communicate back to the test |
| 169 // context. Note the test context doesn't simply inherit this, because the | 170 // context. Note the test context doesn't simply inherit this, because the |
| 170 // delegate is owned by the view. | 171 // delegate is owned by the view. |
| 171 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { | 172 class UnitTestViewDelegate : public app_list::test::AppListTestViewDelegate { |
| 172 public: | 173 public: |
| 173 explicit UnitTestViewDelegate(AppListViewTestContext* parent) | 174 explicit UnitTestViewDelegate(AppListViewTestContext* parent) |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 549 |
| 549 Show(); | 550 Show(); |
| 550 | 551 |
| 551 if (is_landscape()) | 552 if (is_landscape()) |
| 552 EXPECT_EQ(2, GetPaginationModel()->total_pages()); | 553 EXPECT_EQ(2, GetPaginationModel()->total_pages()); |
| 553 else | 554 else |
| 554 EXPECT_EQ(3, GetPaginationModel()->total_pages()); | 555 EXPECT_EQ(3, GetPaginationModel()->total_pages()); |
| 555 | 556 |
| 556 // Change the profile. The original model needs to be kept alive for | 557 // Change the profile. The original model needs to be kept alive for |
| 557 // observers to unregister themselves. | 558 // observers to unregister themselves. |
| 558 scoped_ptr<AppListTestModel> original_test_model( | 559 std::unique_ptr<AppListTestModel> original_test_model( |
| 559 delegate_->ReleaseTestModel()); | 560 delegate_->ReleaseTestModel()); |
| 560 delegate_->set_next_profile_app_count(1); | 561 delegate_->set_next_profile_app_count(1); |
| 561 | 562 |
| 562 // The original ContentsView is destroyed here. | 563 // The original ContentsView is destroyed here. |
| 563 view_->SetProfileByPath(base::FilePath()); | 564 view_->SetProfileByPath(base::FilePath()); |
| 564 EXPECT_EQ(1, GetPaginationModel()->total_pages()); | 565 EXPECT_EQ(1, GetPaginationModel()->total_pages()); |
| 565 | 566 |
| 566 StartPageView* start_page_view = | 567 StartPageView* start_page_view = |
| 567 view_->app_list_main_view()->contents_view()->start_page_view(); | 568 view_->app_list_main_view()->contents_view()->start_page_view(); |
| 568 if (test_type_ == EXPERIMENTAL) | 569 if (test_type_ == EXPERIMENTAL) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 | 696 |
| 696 test_context_.reset(new AppListViewTestContext(GetParam(), container)); | 697 test_context_.reset(new AppListViewTestContext(GetParam(), container)); |
| 697 } | 698 } |
| 698 | 699 |
| 699 void TearDown() override { | 700 void TearDown() override { |
| 700 test_context_.reset(); | 701 test_context_.reset(); |
| 701 views::ViewsTestBase::TearDown(); | 702 views::ViewsTestBase::TearDown(); |
| 702 } | 703 } |
| 703 | 704 |
| 704 protected: | 705 protected: |
| 705 scoped_ptr<AppListViewTestContext> test_context_; | 706 std::unique_ptr<AppListViewTestContext> test_context_; |
| 706 | 707 |
| 707 private: | 708 private: |
| 708 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); | 709 DISALLOW_COPY_AND_ASSIGN(AppListViewTestAura); |
| 709 }; | 710 }; |
| 710 | 711 |
| 711 class AppListViewTestDesktop : public views::ViewsTestBase, | 712 class AppListViewTestDesktop : public views::ViewsTestBase, |
| 712 public ::testing::WithParamInterface<int> { | 713 public ::testing::WithParamInterface<int> { |
| 713 public: | 714 public: |
| 714 AppListViewTestDesktop() {} | 715 AppListViewTestDesktop() {} |
| 715 virtual ~AppListViewTestDesktop() {} | 716 virtual ~AppListViewTestDesktop() {} |
| 716 | 717 |
| 717 // testing::Test overrides: | 718 // testing::Test overrides: |
| 718 void SetUp() override { | 719 void SetUp() override { |
| 719 set_views_delegate(make_scoped_ptr(new AppListViewTestViewsDelegate(this))); | 720 set_views_delegate( |
| 721 base::WrapUnique(new AppListViewTestViewsDelegate(this))); |
| 720 views::ViewsTestBase::SetUp(); | 722 views::ViewsTestBase::SetUp(); |
| 721 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); | 723 test_context_.reset(new AppListViewTestContext(GetParam(), NULL)); |
| 722 } | 724 } |
| 723 | 725 |
| 724 void TearDown() override { | 726 void TearDown() override { |
| 725 test_context_.reset(); | 727 test_context_.reset(); |
| 726 views::ViewsTestBase::TearDown(); | 728 views::ViewsTestBase::TearDown(); |
| 727 } | 729 } |
| 728 | 730 |
| 729 protected: | 731 protected: |
| 730 scoped_ptr<AppListViewTestContext> test_context_; | 732 std::unique_ptr<AppListViewTestContext> test_context_; |
| 731 | 733 |
| 732 private: | 734 private: |
| 733 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { | 735 class AppListViewTestViewsDelegate : public views::TestViewsDelegate { |
| 734 public: | 736 public: |
| 735 explicit AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) | 737 explicit AppListViewTestViewsDelegate(AppListViewTestDesktop* parent) |
| 736 #if defined(OS_CHROMEOS) | 738 #if defined(OS_CHROMEOS) |
| 737 : parent_(parent) | 739 : parent_(parent) |
| 738 #endif | 740 #endif |
| 739 { | 741 { |
| 740 } | 742 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 AppListViewTestAura, | 855 AppListViewTestAura, |
| 854 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 856 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 855 #endif | 857 #endif |
| 856 | 858 |
| 857 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, | 859 INSTANTIATE_TEST_CASE_P(AppListViewTestDesktopInstance, |
| 858 AppListViewTestDesktop, | 860 AppListViewTestDesktop, |
| 859 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); | 861 ::testing::Range<int>(TEST_TYPE_START, TEST_TYPE_END)); |
| 860 | 862 |
| 861 } // namespace test | 863 } // namespace test |
| 862 } // namespace app_list | 864 } // namespace app_list |
| OLD | NEW |