| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/toolbar/toolbar_model.h" | 5 #include "components/toolbar/toolbar_model.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 | 137 |
| 138 // ToolbarModelTest ----------------------------------------------------------- | 138 // ToolbarModelTest ----------------------------------------------------------- |
| 139 | 139 |
| 140 class ToolbarModelTest : public BrowserWithTestWindowTest { | 140 class ToolbarModelTest : public BrowserWithTestWindowTest { |
| 141 public: | 141 public: |
| 142 ToolbarModelTest(); | 142 ToolbarModelTest(); |
| 143 ToolbarModelTest(Browser::Type browser_type, | 143 ToolbarModelTest(Browser::Type browser_type, |
| 144 chrome::HostDesktopType host_desktop_type, | 144 ui::HostDesktopType host_desktop_type, |
| 145 bool hosted_app); | 145 bool hosted_app); |
| 146 ~ToolbarModelTest() override; | 146 ~ToolbarModelTest() override; |
| 147 | 147 |
| 148 // BrowserWithTestWindowTest: | 148 // BrowserWithTestWindowTest: |
| 149 void SetUp() override; | 149 void SetUp() override; |
| 150 | 150 |
| 151 protected: | 151 protected: |
| 152 void NavigateAndCheckText(const GURL& url, | 152 void NavigateAndCheckText(const GURL& url, |
| 153 const base::string16& expected_text, | 153 const base::string16& expected_text, |
| 154 bool would_perform_search_term_replacement, | 154 bool would_perform_search_term_replacement, |
| 155 bool should_display_url); | 155 bool should_display_url); |
| 156 | 156 |
| 157 private: | 157 private: |
| 158 scoped_ptr<base::FieldTrialList> field_trial_list_; | 158 scoped_ptr<base::FieldTrialList> field_trial_list_; |
| 159 | 159 |
| 160 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest); | 160 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest); |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 ToolbarModelTest::ToolbarModelTest() { | 163 ToolbarModelTest::ToolbarModelTest() { |
| 164 } | 164 } |
| 165 | 165 |
| 166 ToolbarModelTest::ToolbarModelTest( | 166 ToolbarModelTest::ToolbarModelTest(Browser::Type browser_type, |
| 167 Browser::Type browser_type, | 167 ui::HostDesktopType host_desktop_type, |
| 168 chrome::HostDesktopType host_desktop_type, | 168 bool hosted_app) |
| 169 bool hosted_app) | 169 : BrowserWithTestWindowTest(browser_type, host_desktop_type, hosted_app) {} |
| 170 : BrowserWithTestWindowTest(browser_type, | |
| 171 host_desktop_type, | |
| 172 hosted_app) { | |
| 173 } | |
| 174 | 170 |
| 175 ToolbarModelTest::~ToolbarModelTest() { | 171 ToolbarModelTest::~ToolbarModelTest() { |
| 176 } | 172 } |
| 177 | 173 |
| 178 void ToolbarModelTest::SetUp() { | 174 void ToolbarModelTest::SetUp() { |
| 179 BrowserWithTestWindowTest::SetUp(); | 175 BrowserWithTestWindowTest::SetUp(); |
| 180 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 176 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 181 profile(), &TemplateURLServiceFactory::BuildInstanceFor); | 177 profile(), &TemplateURLServiceFactory::BuildInstanceFor); |
| 182 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( | 178 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( |
| 183 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); | 179 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 222 |
| 227 class PopupToolbarModelTest : public ToolbarModelTest { | 223 class PopupToolbarModelTest : public ToolbarModelTest { |
| 228 public: | 224 public: |
| 229 PopupToolbarModelTest(); | 225 PopupToolbarModelTest(); |
| 230 ~PopupToolbarModelTest() override; | 226 ~PopupToolbarModelTest() override; |
| 231 | 227 |
| 232 DISALLOW_COPY_AND_ASSIGN(PopupToolbarModelTest); | 228 DISALLOW_COPY_AND_ASSIGN(PopupToolbarModelTest); |
| 233 }; | 229 }; |
| 234 | 230 |
| 235 PopupToolbarModelTest::PopupToolbarModelTest() | 231 PopupToolbarModelTest::PopupToolbarModelTest() |
| 236 : ToolbarModelTest(Browser::TYPE_POPUP, | 232 : ToolbarModelTest(Browser::TYPE_POPUP, |
| 237 chrome::HOST_DESKTOP_TYPE_NATIVE, | 233 ui::HOST_DESKTOP_TYPE_NATIVE, |
| 238 false) { | 234 false) {} |
| 239 } | |
| 240 | 235 |
| 241 PopupToolbarModelTest::~PopupToolbarModelTest() { | 236 PopupToolbarModelTest::~PopupToolbarModelTest() { |
| 242 } | 237 } |
| 243 | 238 |
| 244 // Actual tests --------------------------------------------------------------- | 239 // Actual tests --------------------------------------------------------------- |
| 245 | 240 |
| 246 // Test that we only replace URLs when query extraction and URL replacement | 241 // Test that we only replace URLs when query extraction and URL replacement |
| 247 // are enabled. | 242 // are enabled. |
| 248 TEST_F(ToolbarModelTest, ShouldDisplayURL_QueryExtraction) { | 243 TEST_F(ToolbarModelTest, ShouldDisplayURL_QueryExtraction) { |
| 249 AddTab(browser(), GURL(url::kAboutBlankURL)); | 244 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 350 |
| 356 // Disabling URL replacement should reset to only showing URLs. | 351 // Disabling URL replacement should reset to only showing URLs. |
| 357 browser()->toolbar_model()->set_url_replacement_enabled(false); | 352 browser()->toolbar_model()->set_url_replacement_enabled(false); |
| 358 for (size_t i = 0; i < arraysize(test_items); ++i) { | 353 for (size_t i = 0; i < arraysize(test_items); ++i) { |
| 359 const TestItem& test_item = test_items[i]; | 354 const TestItem& test_item = test_items[i]; |
| 360 NavigateAndCheckText(test_item.url, | 355 NavigateAndCheckText(test_item.url, |
| 361 test_item.expected_text_url_replacement_inactive, | 356 test_item.expected_text_url_replacement_inactive, |
| 362 false, test_item.should_display_url); | 357 false, test_item.should_display_url); |
| 363 } | 358 } |
| 364 } | 359 } |
| OLD | NEW |