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 "athena/home/athena_start_page_view.h" | 5 #include "athena/home/athena_start_page_view.h" |
6 | 6 |
7 #include "athena/home/home_card_constants.h" | 7 #include "athena/home/home_card_constants.h" |
8 #include "base/command_line.h" | 8 #include "athena/test/athena_test_base.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "ui/app_list/app_list_switches.h" | 12 #include "ui/app_list/app_list_switches.h" |
13 #include "ui/app_list/search_box_model.h" | 13 #include "ui/app_list/search_box_model.h" |
14 #include "ui/app_list/test/app_list_test_model.h" | 14 #include "ui/app_list/test/app_list_test_model.h" |
15 #include "ui/app_list/test/app_list_test_view_delegate.h" | 15 #include "ui/app_list/test/app_list_test_view_delegate.h" |
16 #include "ui/app_list/views/search_box_view.h" | 16 #include "ui/app_list/views/search_box_view.h" |
17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/views/controls/textfield/textfield.h" | 18 #include "ui/views/controls/textfield/textfield.h" |
19 #include "ui/views/test/views_test_base.h" | |
20 | 19 |
21 namespace athena { | 20 namespace athena { |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 // The number of dummy applications in this tetst. | 24 // The number of dummy applications in this tetst. |
26 const size_t kNumApps = 10; | 25 const size_t kNumApps = 10; |
27 | 26 |
28 } | 27 } |
29 | 28 |
30 class AthenaTestViewDelegate : public app_list::test::AppListTestViewDelegate { | 29 class AthenaTestViewDelegate : public app_list::test::AppListTestViewDelegate { |
31 public: | 30 public: |
32 AthenaTestViewDelegate() {} | 31 AthenaTestViewDelegate() {} |
33 virtual ~AthenaTestViewDelegate() {} | 32 virtual ~AthenaTestViewDelegate() {} |
34 | 33 |
35 private: | 34 private: |
36 // app_list::AppListViewDelegate: | 35 // app_list::AppListViewDelegate: |
37 virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE { | 36 virtual views::View* CreateStartPageWebView(const gfx::Size& size) OVERRIDE { |
38 return new views::View(); | 37 return new views::View(); |
39 } | 38 } |
40 | 39 |
41 DISALLOW_COPY_AND_ASSIGN(AthenaTestViewDelegate); | 40 DISALLOW_COPY_AND_ASSIGN(AthenaTestViewDelegate); |
42 }; | 41 }; |
43 | 42 |
44 class AthenaStartPageViewTest : public views::ViewsTestBase { | 43 class AthenaStartPageViewTest : public test::AthenaTestBase { |
45 public: | 44 public: |
46 AthenaStartPageViewTest() {} | 45 AthenaStartPageViewTest() {} |
47 virtual ~AthenaStartPageViewTest() {} | 46 virtual ~AthenaStartPageViewTest() {} |
48 | 47 |
49 // testing::Test: | 48 // testing::Test: |
50 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
51 views::ViewsTestBase::SetUp(); | 50 test::AthenaTestBase::SetUp(); |
52 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
53 app_list::switches::kEnableExperimentalAppList); | |
54 app_list::test::AppListTestModel* model = view_delegate_.GetTestModel(); | 51 app_list::test::AppListTestModel* model = view_delegate_.GetTestModel(); |
55 for (size_t i = 0; i < kNumApps; ++i) { | 52 for (size_t i = 0; i < kNumApps; ++i) { |
56 model->AddItem(new app_list::test::AppListTestModel::AppListTestItem( | 53 model->AddItem(new app_list::test::AppListTestModel::AppListTestItem( |
57 base::StringPrintf("id-%" PRIuS, i), model)); | 54 base::StringPrintf("id-%" PRIuS, i), model)); |
58 } | 55 } |
59 | 56 |
60 view_.reset(new AthenaStartPageView(&view_delegate_)); | 57 view_.reset(new AthenaStartPageView(&view_delegate_)); |
61 SetSize(gfx::Size(1280, 800)); | 58 SetSize(gfx::Size(1280, 800)); |
62 } | 59 } |
63 virtual void TearDown() OVERRIDE { | 60 virtual void TearDown() OVERRIDE { |
64 view_.reset(); | 61 view_.reset(); |
65 views::ViewsTestBase::TearDown(); | 62 test::AthenaTestBase::TearDown(); |
66 } | 63 } |
67 | 64 |
68 protected: | 65 protected: |
69 void SetSize(const gfx::Size& new_size) { | 66 void SetSize(const gfx::Size& new_size) { |
70 view_->SetSize(new_size); | 67 view_->SetSize(new_size); |
71 view_->Layout(); | 68 view_->Layout(); |
72 } | 69 } |
73 | 70 |
74 gfx::Rect GetIconsBounds() const { | 71 gfx::Rect GetIconsBounds() const { |
75 return view_->app_icon_container_->layer()->GetTargetBounds(); | 72 return view_->app_icon_container_->layer()->GetTargetBounds(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 EXPECT_GT(base_search_box_bounds.y(), GetSearchBoxBounds().y()); | 220 EXPECT_GT(base_search_box_bounds.y(), GetSearchBoxBounds().y()); |
224 EXPECT_EQ(query, GetVisibleQuery()); | 221 EXPECT_EQ(query, GetVisibleQuery()); |
225 | 222 |
226 SetSearchQuery(base::string16()); | 223 SetSearchQuery(base::string16()); |
227 EXPECT_TRUE(IsLogoVisible()); | 224 EXPECT_TRUE(IsLogoVisible()); |
228 EXPECT_EQ(base_search_box_bounds.ToString(), GetSearchBoxBounds().ToString()); | 225 EXPECT_EQ(base_search_box_bounds.ToString(), GetSearchBoxBounds().ToString()); |
229 EXPECT_TRUE(GetVisibleQuery().empty()); | 226 EXPECT_TRUE(GetVisibleQuery().empty()); |
230 } | 227 } |
231 | 228 |
232 } // namespace athena | 229 } // namespace athena |
OLD | NEW |