OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/toolbar/toolbar_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" |
9 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
10 #include "chrome/test/base/browser_with_test_window_test.h" | 11 #include "chrome/test/base/browser_with_test_window_test.h" |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
13 | 14 |
14 using content::OpenURLParams; | 15 using content::OpenURLParams; |
15 using content::Referrer; | 16 using content::Referrer; |
16 using content::WebContents; | 17 using content::WebContents; |
17 | 18 |
18 class ToolbarModelTest : public BrowserWithTestWindowTest { | 19 class ToolbarModelTest : public BrowserWithTestWindowTest { |
19 public: | 20 public: |
20 ToolbarModelTest() {} | 21 ToolbarModelTest() {} |
21 | 22 |
22 protected: | 23 protected: |
23 void NavigateAndCheckText(const std::string& url, | 24 void NavigateAndCheckText(const std::string& url, |
24 const std::string& expected_text, | 25 const std::string& expected_text, |
25 bool should_display) { | 26 bool should_display) { |
26 WebContents* contents = browser()->GetWebContentsAt(0); | 27 WebContents* contents = chrome::GetWebContentsAt(browser(), 0); |
27 browser()->OpenURL(OpenURLParams( | 28 browser()->OpenURL(OpenURLParams( |
28 GURL(url), Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, | 29 GURL(url), Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, |
29 false)); | 30 false)); |
30 | 31 |
31 // Check while loading. | 32 // Check while loading. |
32 EXPECT_EQ(should_display, browser()->toolbar_model()->ShouldDisplayURL()); | 33 EXPECT_EQ(should_display, browser()->toolbar_model()->ShouldDisplayURL()); |
33 EXPECT_EQ(ASCIIToUTF16(expected_text), | 34 EXPECT_EQ(ASCIIToUTF16(expected_text), |
34 browser()->toolbar_model()->GetText()); | 35 browser()->toolbar_model()->GetText()); |
35 | 36 |
36 // Check after commit. | 37 // Check after commit. |
(...skipping 10 matching lines...) Expand all Loading... |
47 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 48 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
48 | 49 |
49 NavigateAndCheckText("view-source:http://www.google.com", | 50 NavigateAndCheckText("view-source:http://www.google.com", |
50 "view-source:www.google.com", true); | 51 "view-source:www.google.com", true); |
51 NavigateAndCheckText("view-source:chrome://newtab/", | 52 NavigateAndCheckText("view-source:chrome://newtab/", |
52 "view-source:chrome://newtab", true); | 53 "view-source:chrome://newtab", true); |
53 NavigateAndCheckText("chrome-extension://monkey/balls.html", "", false); | 54 NavigateAndCheckText("chrome-extension://monkey/balls.html", "", false); |
54 NavigateAndCheckText("chrome://newtab/", "", false); | 55 NavigateAndCheckText("chrome://newtab/", "", false); |
55 NavigateAndCheckText(chrome::kAboutBlankURL, chrome::kAboutBlankURL, true); | 56 NavigateAndCheckText(chrome::kAboutBlankURL, chrome::kAboutBlankURL, true); |
56 } | 57 } |
OLD | NEW |