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

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

Issue 2232863002: Remove search::GetSearchTerms since it always returns empty string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_query_extract
Patch Set: Android Created 4 years, 4 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
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 void ToolbarModelTest::NavigateAndCheckText( 96 void ToolbarModelTest::NavigateAndCheckText(
97 const GURL& url, 97 const GURL& url,
98 const base::string16& expected_text) { 98 const base::string16& expected_text) {
99 // Check while loading. 99 // Check while loading.
100 content::NavigationController* controller = 100 content::NavigationController* controller =
101 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); 101 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
102 controller->LoadURL(url, content::Referrer(), ui::PAGE_TRANSITION_LINK, 102 controller->LoadURL(url, content::Referrer(), ui::PAGE_TRANSITION_LINK,
103 std::string()); 103 std::string());
104 ToolbarModel* toolbar_model = browser()->toolbar_model(); 104 ToolbarModel* toolbar_model = browser()->toolbar_model();
105 EXPECT_EQ(expected_text, toolbar_model->GetText()); 105 EXPECT_EQ(expected_text, toolbar_model->GetFormattedURL(nullptr));
106 EXPECT_FALSE(toolbar_model->WouldPerformSearchTermReplacement(false));
107 EXPECT_TRUE(toolbar_model->ShouldDisplayURL()); 106 EXPECT_TRUE(toolbar_model->ShouldDisplayURL());
108 107
109 // Check after commit. 108 // Check after commit.
110 CommitPendingLoad(controller); 109 CommitPendingLoad(controller);
111 EXPECT_EQ(expected_text, toolbar_model->GetText()); 110 EXPECT_EQ(expected_text, toolbar_model->GetFormattedURL(nullptr));
112 EXPECT_FALSE(toolbar_model->WouldPerformSearchTermReplacement(false));
113 EXPECT_TRUE(toolbar_model->ShouldDisplayURL()); 111 EXPECT_TRUE(toolbar_model->ShouldDisplayURL());
114 } 112 }
115 113
116 void ToolbarModelTest::NavigateAndCheckElided(const GURL& url) { 114 void ToolbarModelTest::NavigateAndCheckElided(const GURL& url) {
117 // Check while loading. 115 // Check while loading.
118 content::NavigationController* controller = 116 content::NavigationController* controller =
119 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController(); 117 &browser()->tab_strip_model()->GetWebContentsAt(0)->GetController();
120 controller->LoadURL(url, content::Referrer(), ui::PAGE_TRANSITION_LINK, 118 controller->LoadURL(url, content::Referrer(), ui::PAGE_TRANSITION_LINK,
121 std::string()); 119 std::string());
122 ToolbarModel* toolbar_model = browser()->toolbar_model(); 120 ToolbarModel* toolbar_model = browser()->toolbar_model();
123 const base::string16 toolbar_text_before(toolbar_model->GetText()); 121 const base::string16 toolbar_text_before(
122 toolbar_model->GetFormattedURL(nullptr));
124 EXPECT_LT(toolbar_text_before.size(), url.spec().size()); 123 EXPECT_LT(toolbar_text_before.size(), url.spec().size());
125 EXPECT_TRUE(base::EndsWith(toolbar_text_before, 124 EXPECT_TRUE(base::EndsWith(toolbar_text_before,
126 base::string16(gfx::kEllipsisUTF16), 125 base::string16(gfx::kEllipsisUTF16),
127 base::CompareCase::SENSITIVE)); 126 base::CompareCase::SENSITIVE));
128 // Check after commit. 127 // Check after commit.
129 CommitPendingLoad(controller); 128 CommitPendingLoad(controller);
130 const base::string16 toolbar_text_after(toolbar_model->GetText()); 129 const base::string16 toolbar_text_after(
130 toolbar_model->GetFormattedURL(nullptr));
131 EXPECT_LT(toolbar_text_after.size(), url.spec().size()); 131 EXPECT_LT(toolbar_text_after.size(), url.spec().size());
132 EXPECT_TRUE(base::EndsWith(toolbar_text_after, 132 EXPECT_TRUE(base::EndsWith(toolbar_text_after,
133 base::string16(gfx::kEllipsisUTF16), 133 base::string16(gfx::kEllipsisUTF16),
134 base::CompareCase::SENSITIVE)); 134 base::CompareCase::SENSITIVE));
135 } 135 }
136 136
137 // Actual tests --------------------------------------------------------------- 137 // Actual tests ---------------------------------------------------------------
138 138
139 // Test URL display. 139 // Test URL display.
140 TEST_F(ToolbarModelTest, ShouldDisplayURL) { 140 TEST_F(ToolbarModelTest, ShouldDisplayURL) {
141 AddTab(browser(), GURL(url::kAboutBlankURL)); 141 AddTab(browser(), GURL(url::kAboutBlankURL));
142 142
143 for (const TestItem& test_item : test_items) { 143 for (const TestItem& test_item : test_items) {
144 NavigateAndCheckText(test_item.url, test_item.expected_text); 144 NavigateAndCheckText(test_item.url, test_item.expected_text);
145 } 145 }
146 } 146 }
147 147
148 TEST_F(ToolbarModelTest, ShouldElideLongURLs) { 148 TEST_F(ToolbarModelTest, ShouldElideLongURLs) {
149 AddTab(browser(), GURL(url::kAboutBlankURL)); 149 AddTab(browser(), GURL(url::kAboutBlankURL));
150 const std::string long_text(content::kMaxURLDisplayChars + 1024, '0'); 150 const std::string long_text(content::kMaxURLDisplayChars + 1024, '0');
151 NavigateAndCheckElided( 151 NavigateAndCheckElided(
152 GURL(std::string("https://www.foo.com/?") + long_text)); 152 GURL(std::string("https://www.foo.com/?") + long_text));
153 NavigateAndCheckElided(GURL(std::string("data:abc") + long_text)); 153 NavigateAndCheckElided(GURL(std::string("data:abc") + long_text));
154 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/chrome_toolbar_model_delegate.cc ('k') | chrome/browser/ui/views/omnibox/omnibox_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698