| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 | 143 |
| 144 // ToolbarModelTest ----------------------------------------------------------- | 144 // ToolbarModelTest ----------------------------------------------------------- |
| 145 | 145 |
| 146 class ToolbarModelTest : public BrowserWithTestWindowTest { | 146 class ToolbarModelTest : public BrowserWithTestWindowTest { |
| 147 public: | 147 public: |
| 148 ToolbarModelTest(); | 148 ToolbarModelTest(); |
| 149 ToolbarModelTest(Browser::Type browser_type, | 149 ToolbarModelTest(Browser::Type browser_type, bool hosted_app); |
| 150 chrome::HostDesktopType host_desktop_type, | |
| 151 bool hosted_app); | |
| 152 ~ToolbarModelTest() override; | 150 ~ToolbarModelTest() override; |
| 153 | 151 |
| 154 // BrowserWithTestWindowTest: | 152 // BrowserWithTestWindowTest: |
| 155 void SetUp() override; | 153 void SetUp() override; |
| 156 | 154 |
| 157 protected: | 155 protected: |
| 158 void NavigateAndCheckText(const GURL& url, | 156 void NavigateAndCheckText(const GURL& url, |
| 159 const base::string16& expected_text, | 157 const base::string16& expected_text, |
| 160 bool would_perform_search_term_replacement, | 158 bool would_perform_search_term_replacement, |
| 161 bool should_display_url); | 159 bool should_display_url); |
| 162 void NavigateAndCheckElided(const GURL& https_url); | 160 void NavigateAndCheckElided(const GURL& https_url); |
| 163 | 161 |
| 164 private: | 162 private: |
| 165 scoped_ptr<base::FieldTrialList> field_trial_list_; | 163 scoped_ptr<base::FieldTrialList> field_trial_list_; |
| 166 | 164 |
| 167 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest); | 165 DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest); |
| 168 }; | 166 }; |
| 169 | 167 |
| 170 ToolbarModelTest::ToolbarModelTest() { | 168 ToolbarModelTest::ToolbarModelTest() { |
| 171 } | 169 } |
| 172 | 170 |
| 173 ToolbarModelTest::ToolbarModelTest( | 171 ToolbarModelTest::ToolbarModelTest(Browser::Type browser_type, bool hosted_app) |
| 174 Browser::Type browser_type, | 172 : BrowserWithTestWindowTest(browser_type, hosted_app) {} |
| 175 chrome::HostDesktopType host_desktop_type, | |
| 176 bool hosted_app) | |
| 177 : BrowserWithTestWindowTest(browser_type, | |
| 178 host_desktop_type, | |
| 179 hosted_app) { | |
| 180 } | |
| 181 | 173 |
| 182 ToolbarModelTest::~ToolbarModelTest() { | 174 ToolbarModelTest::~ToolbarModelTest() { |
| 183 } | 175 } |
| 184 | 176 |
| 185 void ToolbarModelTest::SetUp() { | 177 void ToolbarModelTest::SetUp() { |
| 186 BrowserWithTestWindowTest::SetUp(); | 178 BrowserWithTestWindowTest::SetUp(); |
| 187 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 179 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 188 profile(), &TemplateURLServiceFactory::BuildInstanceFor); | 180 profile(), &TemplateURLServiceFactory::BuildInstanceFor); |
| 189 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( | 181 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( |
| 190 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); | 182 profile(), &AutocompleteClassifierFactory::BuildInstanceFor); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 246 |
| 255 class PopupToolbarModelTest : public ToolbarModelTest { | 247 class PopupToolbarModelTest : public ToolbarModelTest { |
| 256 public: | 248 public: |
| 257 PopupToolbarModelTest(); | 249 PopupToolbarModelTest(); |
| 258 ~PopupToolbarModelTest() override; | 250 ~PopupToolbarModelTest() override; |
| 259 | 251 |
| 260 DISALLOW_COPY_AND_ASSIGN(PopupToolbarModelTest); | 252 DISALLOW_COPY_AND_ASSIGN(PopupToolbarModelTest); |
| 261 }; | 253 }; |
| 262 | 254 |
| 263 PopupToolbarModelTest::PopupToolbarModelTest() | 255 PopupToolbarModelTest::PopupToolbarModelTest() |
| 264 : ToolbarModelTest(Browser::TYPE_POPUP, | 256 : ToolbarModelTest(Browser::TYPE_POPUP, false) {} |
| 265 chrome::HOST_DESKTOP_TYPE_NATIVE, | |
| 266 false) { | |
| 267 } | |
| 268 | 257 |
| 269 PopupToolbarModelTest::~PopupToolbarModelTest() { | 258 PopupToolbarModelTest::~PopupToolbarModelTest() { |
| 270 } | 259 } |
| 271 | 260 |
| 272 // Actual tests --------------------------------------------------------------- | 261 // Actual tests --------------------------------------------------------------- |
| 273 | 262 |
| 274 // Test that we only replace URLs when query extraction and URL replacement | 263 // Test that we only replace URLs when query extraction and URL replacement |
| 275 // are enabled. | 264 // are enabled. |
| 276 TEST_F(ToolbarModelTest, ShouldDisplayURL_QueryExtraction) { | 265 TEST_F(ToolbarModelTest, ShouldDisplayURL_QueryExtraction) { |
| 277 AddTab(browser(), GURL(url::kAboutBlankURL)); | 266 AddTab(browser(), GURL(url::kAboutBlankURL)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 | 389 |
| 401 // Disabling URL replacement should reset to only showing URLs. | 390 // Disabling URL replacement should reset to only showing URLs. |
| 402 browser()->toolbar_model()->set_url_replacement_enabled(false); | 391 browser()->toolbar_model()->set_url_replacement_enabled(false); |
| 403 for (size_t i = 0; i < arraysize(test_items); ++i) { | 392 for (size_t i = 0; i < arraysize(test_items); ++i) { |
| 404 const TestItem& test_item = test_items[i]; | 393 const TestItem& test_item = test_items[i]; |
| 405 NavigateAndCheckText(test_item.url, | 394 NavigateAndCheckText(test_item.url, |
| 406 test_item.expected_text_url_replacement_inactive, | 395 test_item.expected_text_url_replacement_inactive, |
| 407 false, test_item.should_display_url); | 396 false, test_item.should_display_url); |
| 408 } | 397 } |
| 409 } | 398 } |
| OLD | NEW |