| Index: ui/app_list/views/contents_view_unittest.cc
|
| diff --git a/ui/app_list/views/contents_view_unittest.cc b/ui/app_list/views/contents_view_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8c2be1ce8d8ef4b826a14725ad358df89944bf7d
|
| --- /dev/null
|
| +++ b/ui/app_list/views/contents_view_unittest.cc
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/app_list/views/contents_view.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/app_list/app_list_switches.h"
|
| +#include "ui/app_list/test/app_list_test_model.h"
|
| +#include "ui/app_list/test/app_list_test_view_delegate.h"
|
| +#include "ui/app_list/views/app_list_main_view.h"
|
| +#include "ui/app_list/views/contents_animator.h"
|
| +#include "ui/app_list/views/search_box_view.h"
|
| +
|
| +namespace app_list {
|
| +namespace test {
|
| +
|
| +class ContentsViewTest : public testing::Test {
|
| + public:
|
| + ContentsViewTest() {
|
| + delegate_.reset(new AppListTestViewDelegate());
|
| + main_view_.reset(new app_list::AppListMainView(delegate_.get()));
|
| + search_box_view_.reset(
|
| + new SearchBoxView(main_view_.get(), delegate_.get()));
|
| +
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitch(
|
| + switches::kEnableExperimentalAppList);
|
| + main_view_->Init(NULL, 0, search_box_view_.get());
|
| + DCHECK(GetContentsView());
|
| + }
|
| +
|
| + ~ContentsViewTest() override {}
|
| +
|
| + protected:
|
| + ContentsView* GetContentsView() const { return main_view_->contents_view(); }
|
| +
|
| + private:
|
| + scoped_ptr<AppListTestViewDelegate> delegate_;
|
| + scoped_ptr<AppListMainView> main_view_;
|
| + scoped_ptr<SearchBoxView> search_box_view_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ContentsViewTest);
|
| +};
|
| +
|
| +TEST_F(ContentsViewTest, CustomAnimationsTest) {
|
| + ContentsView* contents_view = GetContentsView();
|
| + ContentsAnimator* animator;
|
| + bool reverse = true; // Set to true to make sure it is written.
|
| +
|
| + // A transition without a custom animation.
|
| + animator = contents_view->GetAnimatorForTransitionForTests(
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_START),
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS),
|
| + &reverse);
|
| + EXPECT_EQ("DefaultAnimator", animator->NameForTests());
|
| + EXPECT_FALSE(reverse);
|
| +
|
| + // Test some custom animations.
|
| + reverse = true;
|
| + animator = contents_view->GetAnimatorForTransitionForTests(
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_START),
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_APPS), &reverse);
|
| + EXPECT_EQ("StartToAppsAnimator", animator->NameForTests());
|
| + EXPECT_FALSE(reverse);
|
| +
|
| + reverse = false;
|
| + animator = contents_view->GetAnimatorForTransitionForTests(
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_APPS),
|
| + contents_view->GetPageIndexForState(AppListModel::STATE_START), &reverse);
|
| + EXPECT_EQ("StartToAppsAnimator", animator->NameForTests());
|
| + EXPECT_TRUE(reverse);
|
| +}
|
| +
|
| +} // namespace test
|
| +} // namespace app_list
|
|
|