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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 class MockInstantServiceObserver : public InstantServiceObserver { | 29 class MockInstantServiceObserver : public InstantServiceObserver { |
30 public: | 30 public: |
31 MOCK_METHOD0(DefaultSearchProviderChanged, void()); | 31 MOCK_METHOD0(DefaultSearchProviderChanged, void()); |
32 MOCK_METHOD1(OmniboxStartMarginChanged, void(int)); | 32 MOCK_METHOD1(OmniboxStartMarginChanged, void(int)); |
33 }; | 33 }; |
34 | 34 |
35 class InstantServiceTest : public InstantUnitTestBase { | 35 class InstantServiceTest : public InstantUnitTestBase { |
36 protected: | 36 protected: |
37 virtual void SetUp() OVERRIDE { | 37 virtual void SetUp() override { |
38 InstantUnitTestBase::SetUp(); | 38 InstantUnitTestBase::SetUp(); |
39 | 39 |
40 instant_service_observer_.reset(new MockInstantServiceObserver()); | 40 instant_service_observer_.reset(new MockInstantServiceObserver()); |
41 instant_service_->AddObserver(instant_service_observer_.get()); | 41 instant_service_->AddObserver(instant_service_observer_.get()); |
42 } | 42 } |
43 | 43 |
44 virtual void TearDown() OVERRIDE { | 44 virtual void TearDown() override { |
45 instant_service_->RemoveObserver(instant_service_observer_.get()); | 45 instant_service_->RemoveObserver(instant_service_observer_.get()); |
46 InstantUnitTestBase::TearDown(); | 46 InstantUnitTestBase::TearDown(); |
47 } | 47 } |
48 | 48 |
49 InstantSearchPrerenderer* GetInstantSearchPrerenderer() { | 49 InstantSearchPrerenderer* GetInstantSearchPrerenderer() { |
50 return instant_service_->instant_search_prerenderer(); | 50 return instant_service_->instant_search_prerenderer(); |
51 } | 51 } |
52 | 52 |
53 void UpdateOmniboxStartMargin(int start_margin) { | 53 void UpdateOmniboxStartMargin(int start_margin) { |
54 instant_service_->OnOmniboxStartMarginChanged(start_margin); | 54 instant_service_->OnOmniboxStartMarginChanged(start_margin); |
55 } | 55 } |
56 | 56 |
57 scoped_ptr<MockInstantServiceObserver> instant_service_observer_; | 57 scoped_ptr<MockInstantServiceObserver> instant_service_observer_; |
58 }; | 58 }; |
59 | 59 |
60 class InstantServiceEnabledTest : public InstantServiceTest { | 60 class InstantServiceEnabledTest : public InstantServiceTest { |
61 protected: | 61 protected: |
62 virtual void SetUp() OVERRIDE { | 62 virtual void SetUp() override { |
63 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 63 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
64 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); | 64 "EmbeddedSearch", "Group1 use_cacheable_ntp:1")); |
65 InstantServiceTest::SetUp(); | 65 InstantServiceTest::SetUp(); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
69 TEST_F(InstantServiceEnabledTest, DispatchDefaultSearchProviderChanged) { | 69 TEST_F(InstantServiceEnabledTest, DispatchDefaultSearchProviderChanged) { |
70 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) | 70 EXPECT_CALL(*instant_service_observer_.get(), DefaultSearchProviderChanged()) |
71 .Times(1); | 71 .Times(1); |
72 | 72 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 NotifyGoogleBaseURLUpdate(new_base_url); | 156 NotifyGoogleBaseURLUpdate(new_base_url); |
157 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); | 157 EXPECT_NE(old_prerenderer, GetInstantSearchPrerenderer()); |
158 } | 158 } |
159 | 159 |
160 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { | 160 TEST_F(InstantServiceTest, OmniboxStartMarginChanged) { |
161 int new_start_margin = 92; | 161 int new_start_margin = 92; |
162 EXPECT_CALL(*instant_service_observer_.get(), | 162 EXPECT_CALL(*instant_service_observer_.get(), |
163 OmniboxStartMarginChanged(new_start_margin)).Times(1); | 163 OmniboxStartMarginChanged(new_start_margin)).Times(1); |
164 UpdateOmniboxStartMargin(new_start_margin); | 164 UpdateOmniboxStartMargin(new_start_margin); |
165 } | 165 } |
OLD | NEW |