Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_model_unittest.cc

Issue 8224023: Don't show URL for pending new navigations initiated by the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add IsBrowserInitiated helper. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/toolbar/toolbar_model.h" 9 #include "chrome/browser/ui/toolbar/toolbar_model.h"
10 #include "chrome/test/base/browser_with_test_window_test.h" 10 #include "chrome/test/base/browser_with_test_window_test.h"
11 #include "content/browser/tab_contents/tab_contents.h"
11 12
12 typedef BrowserWithTestWindowTest ToolbarModelTest; 13 typedef BrowserWithTestWindowTest ToolbarModelTest;
13 14
15 // Test that URLs are correctly shown or hidden both during navigation and
16 // after commit.
14 TEST_F(ToolbarModelTest, ShouldDisplayURL) { 17 TEST_F(ToolbarModelTest, ShouldDisplayURL) {
18 AddTab(browser(), GURL("about:blank"));
Paweł Hajdan Jr. 2011/10/11 22:26:18 nit: Please use a constant for this. There is one
Charlie Reis 2011/10/12 21:55:56 Done.
19 TabContents* contents = browser()->GetTabContentsAt(0);
20
15 browser()->OpenURL(GURL("view-source:http://www.google.com"), 21 browser()->OpenURL(GURL("view-source:http://www.google.com"),
16 GURL(), CURRENT_TAB, PageTransition::TYPED); 22 GURL(), CURRENT_TAB, PageTransition::TYPED);
17 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL()); 23 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
18 EXPECT_EQ(ASCIIToUTF16("view-source:www.google.com"), 24 EXPECT_EQ(ASCIIToUTF16("view-source:www.google.com"),
19 browser()->toolbar_model()->GetText()); 25 browser()->toolbar_model()->GetText());
26 CommitPendingLoad(&contents->controller());
27 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
28 EXPECT_EQ(ASCIIToUTF16("view-source:www.google.com"),
29 browser()->toolbar_model()->GetText());
20 30
21 browser()->OpenURL(GURL("view-source:chrome://newtab/"), 31 browser()->OpenURL(GURL("view-source:chrome://newtab/"),
22 GURL(), CURRENT_TAB, PageTransition::TYPED); 32 GURL(), CURRENT_TAB, PageTransition::TYPED);
23 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL()); 33 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
24 EXPECT_EQ(ASCIIToUTF16("view-source:chrome://newtab"), 34 EXPECT_EQ(ASCIIToUTF16("view-source:chrome://newtab"),
25 browser()->toolbar_model()->GetText()); 35 browser()->toolbar_model()->GetText());
36 CommitPendingLoad(&contents->controller());
37 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
38 EXPECT_EQ(ASCIIToUTF16("view-source:chrome://newtab"),
39 browser()->toolbar_model()->GetText());
26 40
27 browser()->OpenURL(GURL("chrome-extension://monkey/balls.html"), 41 browser()->OpenURL(GURL("chrome-extension://monkey/balls.html"),
28 GURL(), CURRENT_TAB, PageTransition::TYPED); 42 GURL(), CURRENT_TAB, PageTransition::TYPED);
29 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL()); 43 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL());
30 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText()); 44 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText());
45 CommitPendingLoad(&contents->controller());
46 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL());
47 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText());
31 48
32 browser()->OpenURL(GURL("chrome://newtab/"), 49 browser()->OpenURL(GURL("chrome://newtab/"),
33 GURL(), CURRENT_TAB, PageTransition::TYPED); 50 GURL(), CURRENT_TAB, PageTransition::TYPED);
34 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL()); 51 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL());
35 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText()); 52 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText());
53 CommitPendingLoad(&contents->controller());
54 EXPECT_FALSE(browser()->toolbar_model()->ShouldDisplayURL());
55 EXPECT_EQ(ASCIIToUTF16(""), browser()->toolbar_model()->GetText());
36 56
37 browser()->OpenURL(GURL("about:blank"), 57 browser()->OpenURL(GURL("about:blank"),
38 GURL(), CURRENT_TAB, PageTransition::TYPED); 58 GURL(), CURRENT_TAB, PageTransition::TYPED);
39 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL()); 59 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
40 EXPECT_EQ(ASCIIToUTF16("about:blank"), 60 EXPECT_EQ(ASCIIToUTF16("about:blank"),
41 browser()->toolbar_model()->GetText()); 61 browser()->toolbar_model()->GetText());
62 CommitPendingLoad(&contents->controller());
63 EXPECT_TRUE(browser()->toolbar_model()->ShouldDisplayURL());
64 EXPECT_EQ(ASCIIToUTF16("about:blank"),
Paweł Hajdan Jr. 2011/10/11 22:26:18 nit: This too.
Charlie Reis 2011/10/12 21:55:56 Done.
65 browser()->toolbar_model()->GetText());
42 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698