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 "chrome/browser/ui/search/search_model.h" | 5 #include "chrome/browser/ui/search/search_model.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/ui/search/search_model_observer.h" | 8 #include "chrome/browser/ui/search/search_model_observer.h" |
9 #include "chrome/browser/ui/search/search_tab_helper.h" | 9 #include "chrome/browser/ui/search/search_tab_helper.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/search_types.h" | 11 #include "chrome/common/search_types.h" |
12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 12 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class MockSearchModelObserver : public SearchModelObserver { | 16 class MockSearchModelObserver : public SearchModelObserver { |
17 public: | 17 public: |
18 MockSearchModelObserver(); | 18 MockSearchModelObserver(); |
19 virtual ~MockSearchModelObserver(); | 19 virtual ~MockSearchModelObserver(); |
20 | 20 |
21 virtual void ModelChanged(const SearchModel::State& old_state, | 21 virtual void ModelChanged(const SearchModel::State& old_state, |
22 const SearchModel::State& new_state) OVERRIDE; | 22 const SearchModel::State& new_state) override; |
23 | 23 |
24 void VerifySearchModelStates(const SearchModel::State& expected_old_state, | 24 void VerifySearchModelStates(const SearchModel::State& expected_old_state, |
25 const SearchModel::State& expected_new_state); | 25 const SearchModel::State& expected_new_state); |
26 | 26 |
27 void VerifyNotificationCount(int expected_count); | 27 void VerifyNotificationCount(int expected_count); |
28 | 28 |
29 private: | 29 private: |
30 // How many times we've seen search model changed notifications. | 30 // How many times we've seen search model changed notifications. |
31 int modelchanged_notification_count_; | 31 int modelchanged_notification_count_; |
32 | 32 |
(...skipping 26 matching lines...) Expand all Loading... |
59 } | 59 } |
60 | 60 |
61 void MockSearchModelObserver::VerifyNotificationCount(int expected_count) { | 61 void MockSearchModelObserver::VerifyNotificationCount(int expected_count) { |
62 EXPECT_EQ(modelchanged_notification_count_, expected_count); | 62 EXPECT_EQ(modelchanged_notification_count_, expected_count); |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 class SearchModelTest : public ChromeRenderViewHostTestHarness { | 67 class SearchModelTest : public ChromeRenderViewHostTestHarness { |
68 public: | 68 public: |
69 virtual void SetUp() OVERRIDE; | 69 virtual void SetUp() override; |
70 virtual void TearDown() OVERRIDE; | 70 virtual void TearDown() override; |
71 | 71 |
72 MockSearchModelObserver mock_observer; | 72 MockSearchModelObserver mock_observer; |
73 SearchModel* model; | 73 SearchModel* model; |
74 }; | 74 }; |
75 | 75 |
76 void SearchModelTest::SetUp() { | 76 void SearchModelTest::SetUp() { |
77 ChromeRenderViewHostTestHarness::SetUp(); | 77 ChromeRenderViewHostTestHarness::SetUp(); |
78 SearchTabHelper::CreateForWebContents(web_contents()); | 78 SearchTabHelper::CreateForWebContents(web_contents()); |
79 SearchTabHelper* search_tab_helper = | 79 SearchTabHelper* search_tab_helper = |
80 SearchTabHelper::FromWebContents(web_contents()); | 80 SearchTabHelper::FromWebContents(web_contents()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 SearchModel::State expected_old_state = model->state(); | 149 SearchModel::State expected_old_state = model->state(); |
150 SearchModel::State expected_new_state(model->state()); | 150 SearchModel::State expected_new_state(model->state()); |
151 expected_new_state.voice_search_supported = true; | 151 expected_new_state.voice_search_supported = true; |
152 | 152 |
153 model->SetVoiceSearchSupported(true); | 153 model->SetVoiceSearchSupported(true); |
154 mock_observer.VerifySearchModelStates(expected_old_state, expected_new_state); | 154 mock_observer.VerifySearchModelStates(expected_old_state, expected_new_state); |
155 mock_observer.VerifyNotificationCount(1); | 155 mock_observer.VerifyNotificationCount(1); |
156 EXPECT_TRUE(model->voice_search_supported()); | 156 EXPECT_TRUE(model->voice_search_supported()); |
157 } | 157 } |
OLD | NEW |