| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
| 10 #include "chrome/browser/ui/search/instant_controller.h" | 10 #include "chrome/browser/ui/search/instant_controller.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 std::string test_instant_url_; | 83 std::string test_instant_url_; |
| 84 bool test_extended_enabled_; | 84 bool test_extended_enabled_; |
| 85 scoped_ptr<InstantOverlay> test_overlay_; | 85 scoped_ptr<InstantOverlay> test_overlay_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class InstantControllerTest : public testing::Test { | 88 class InstantControllerTest : public testing::Test { |
| 89 public: | 89 public: |
| 90 InstantControllerTest() | 90 InstantControllerTest() |
| 91 : loop_(MessageLoop::TYPE_DEFAULT), | 91 : loop_(base::MessageLoop::TYPE_DEFAULT), |
| 92 instant_controller_(new TestableInstantController()) { | 92 instant_controller_(new TestableInstantController()) { |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void SetUp() OVERRIDE { | 95 virtual void SetUp() OVERRIDE { |
| 96 base::StatisticsRecorder::Initialize(); | 96 base::StatisticsRecorder::Initialize(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 TestableInstantController* instant_controller() { | 99 TestableInstantController* instant_controller() { |
| 100 return instant_controller_.get(); | 100 return instant_controller_.get(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 MessageLoop loop_; | 104 base::MessageLoop loop_; |
| 105 scoped_ptr<TestableInstantController> instant_controller_; | 105 scoped_ptr<TestableInstantController> instant_controller_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 TEST_F(InstantControllerTest, ShouldSwitchToLocalOverlayReturn) { | 108 TEST_F(InstantControllerTest, ShouldSwitchToLocalOverlayReturn) { |
| 109 InstantController::InstantFallbackReason fallback_reason; | 109 InstantController::InstantFallbackReason fallback_reason; |
| 110 | 110 |
| 111 instant_controller()->set_extended_enabled(false); | 111 instant_controller()->set_extended_enabled(false); |
| 112 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); | 112 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); |
| 113 ASSERT_EQ(fallback_reason, InstantController::INSTANT_FALLBACK_NONE); | 113 ASSERT_EQ(fallback_reason, InstantController::INSTANT_FALLBACK_NONE); |
| 114 | 114 |
| 115 instant_controller()->set_extended_enabled(true); | 115 instant_controller()->set_extended_enabled(true); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 138 instant_controller()->set_instant_url(instant_url); | 138 instant_controller()->set_instant_url(instant_url); |
| 139 test_overlay->set_supports_instant(false); | 139 test_overlay->set_supports_instant(false); |
| 140 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); | 140 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); |
| 141 ASSERT_EQ(fallback_reason, | 141 ASSERT_EQ(fallback_reason, |
| 142 InstantController::INSTANT_FALLBACK_INSTANT_NOT_SUPPORTED); | 142 InstantController::INSTANT_FALLBACK_INSTANT_NOT_SUPPORTED); |
| 143 | 143 |
| 144 test_overlay->set_supports_instant(true); | 144 test_overlay->set_supports_instant(true); |
| 145 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); | 145 fallback_reason = instant_controller()->ShouldSwitchToLocalOverlay(); |
| 146 ASSERT_EQ(fallback_reason, InstantController::INSTANT_FALLBACK_NONE); | 146 ASSERT_EQ(fallback_reason, InstantController::INSTANT_FALLBACK_NONE); |
| 147 } | 147 } |
| OLD | NEW |