| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/app_list/views/contents_view.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/app_list/app_list_switches.h" |
| 11 #include "ui/app_list/test/app_list_test_model.h" |
| 12 #include "ui/app_list/test/app_list_test_view_delegate.h" |
| 13 #include "ui/app_list/views/app_list_main_view.h" |
| 14 #include "ui/app_list/views/contents_animator.h" |
| 15 #include "ui/app_list/views/search_box_view.h" |
| 16 |
| 17 namespace app_list { |
| 18 namespace test { |
| 19 |
| 20 class ContentsViewTest : public testing::Test { |
| 21 public: |
| 22 ContentsViewTest() { |
| 23 delegate_.reset(new AppListTestViewDelegate()); |
| 24 main_view_.reset(new app_list::AppListMainView(delegate_.get())); |
| 25 search_box_view_.reset( |
| 26 new SearchBoxView(main_view_.get(), delegate_.get())); |
| 27 |
| 28 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 29 switches::kEnableExperimentalAppList); |
| 30 main_view_->Init(NULL, 0, search_box_view_.get()); |
| 31 DCHECK(GetContentsView()); |
| 32 } |
| 33 |
| 34 ~ContentsViewTest() override {} |
| 35 |
| 36 protected: |
| 37 ContentsView* GetContentsView() const { return main_view_->contents_view(); } |
| 38 |
| 39 private: |
| 40 scoped_ptr<AppListTestViewDelegate> delegate_; |
| 41 scoped_ptr<AppListMainView> main_view_; |
| 42 scoped_ptr<SearchBoxView> search_box_view_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ContentsViewTest); |
| 45 }; |
| 46 |
| 47 TEST_F(ContentsViewTest, CustomAnimationsTest) { |
| 48 ContentsView* contents_view = GetContentsView(); |
| 49 ContentsAnimator* animator; |
| 50 bool reverse = true; // Set to true to make sure it is written. |
| 51 |
| 52 // A transition without a custom animation. |
| 53 animator = contents_view->GetAnimatorForTransitionForTests( |
| 54 contents_view->GetPageIndexForState(AppListModel::STATE_START), |
| 55 contents_view->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS), |
| 56 &reverse); |
| 57 EXPECT_EQ("DefaultAnimator", animator->NameForTests()); |
| 58 EXPECT_FALSE(reverse); |
| 59 |
| 60 // Test some custom animations. |
| 61 reverse = true; |
| 62 animator = contents_view->GetAnimatorForTransitionForTests( |
| 63 contents_view->GetPageIndexForState(AppListModel::STATE_START), |
| 64 contents_view->GetPageIndexForState(AppListModel::STATE_APPS), &reverse); |
| 65 EXPECT_EQ("StartToAppsAnimator", animator->NameForTests()); |
| 66 EXPECT_FALSE(reverse); |
| 67 |
| 68 reverse = false; |
| 69 animator = contents_view->GetAnimatorForTransitionForTests( |
| 70 contents_view->GetPageIndexForState(AppListModel::STATE_APPS), |
| 71 contents_view->GetPageIndexForState(AppListModel::STATE_START), &reverse); |
| 72 EXPECT_EQ("StartToAppsAnimator", animator->NameForTests()); |
| 73 EXPECT_TRUE(reverse); |
| 74 } |
| 75 |
| 76 } // namespace test |
| 77 } // namespace app_list |
| OLD | NEW |