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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_browsertest.cc

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_input.h" 10 #include "chrome/browser/autocomplete/autocomplete_input.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/common/url_constants.h" 29 #include "chrome/common/url_constants.h"
30 #include "chrome/test/base/in_process_browser_test.h" 30 #include "chrome/test/base/in_process_browser_test.h"
31 #include "chrome/test/base/test_switches.h" 31 #include "chrome/test/base/test_switches.h"
32 #include "chrome/test/base/ui_test_utils.h" 32 #include "chrome/test/base/ui_test_utils.h"
33 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
35 #include "testing/gtest/include/gtest/gtest.h" 35 #include "testing/gtest/include/gtest/gtest.h"
36 36
37 namespace { 37 namespace {
38 38
39 string16 AutocompleteResultAsString(const AutocompleteResult& result) { 39 base::string16 AutocompleteResultAsString(const AutocompleteResult& result) {
40 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size())); 40 std::string output(base::StringPrintf("{%" PRIuS "} ", result.size()));
41 for (size_t i = 0; i < result.size(); ++i) { 41 for (size_t i = 0; i < result.size(); ++i) {
42 AutocompleteMatch match = result.match_at(i); 42 AutocompleteMatch match = result.match_at(i);
43 output.append(base::StringPrintf("[\"%s\" by \"%s\"] ", 43 output.append(base::StringPrintf("[\"%s\" by \"%s\"] ",
44 UTF16ToUTF8(match.contents).c_str(), 44 UTF16ToUTF8(match.contents).c_str(),
45 match.provider->GetName())); 45 match.provider->GetName()));
46 } 46 }
47 return UTF8ToUTF16(output); 47 return UTF8ToUTF16(output);
48 } 48 }
49 49
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 HistoryServiceFactory::GetForProfile(browser()->profile(), 130 HistoryServiceFactory::GetForProfile(browser()->profile(),
131 Profile::EXPLICIT_ACCESS)); 131 Profile::EXPLICIT_ACCESS));
132 132
133 LocationBar* location_bar = GetLocationBar(); 133 LocationBar* location_bar = GetLocationBar();
134 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 134 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
135 AutocompleteController* autocomplete_controller = GetAutocompleteController(); 135 AutocompleteController* autocomplete_controller = GetAutocompleteController();
136 136
137 { 137 {
138 omnibox_view->model()->SetInputInProgress(true); 138 omnibox_view->model()->SetInputInProgress(true);
139 autocomplete_controller->Start(AutocompleteInput( 139 autocomplete_controller->Start(AutocompleteInput(
140 ASCIIToUTF16("chrome"), string16::npos, string16(), GURL(), 140 ASCIIToUTF16("chrome"), base::string16::npos, base::string16(), GURL(),
141 AutocompleteInput::NTP, true, false, true, 141 AutocompleteInput::NTP, true, false, true,
142 AutocompleteInput::SYNCHRONOUS_MATCHES)); 142 AutocompleteInput::SYNCHRONOUS_MATCHES));
143 143
144 EXPECT_TRUE(autocomplete_controller->done()); 144 EXPECT_TRUE(autocomplete_controller->done());
145 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 145 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
146 EXPECT_TRUE(omnibox_view->GetText().empty()); 146 EXPECT_TRUE(omnibox_view->GetText().empty());
147 EXPECT_TRUE(omnibox_view->IsSelectAll()); 147 EXPECT_TRUE(omnibox_view->IsSelectAll());
148 const AutocompleteResult& result = autocomplete_controller->result(); 148 const AutocompleteResult& result = autocomplete_controller->result();
149 // We get two matches because we have a provider for extension apps and the 149 // We get two matches because we have a provider for extension apps and the
150 // Chrome Web Store is a built-in Extension app. For this test, we only care 150 // Chrome Web Store is a built-in Extension app. For this test, we only care
(...skipping 21 matching lines...) Expand all
172 return; 172 return;
173 #endif 173 #endif
174 174
175 WaitForTemplateURLServiceToLoad(); 175 WaitForTemplateURLServiceToLoad();
176 // http://code.google.com/p/chromium/issues/detail?id=38385 176 // http://code.google.com/p/chromium/issues/detail?id=38385
177 // Make sure that tabbing away from an empty omnibox causes a revert 177 // Make sure that tabbing away from an empty omnibox causes a revert
178 // and select all. 178 // and select all.
179 LocationBar* location_bar = GetLocationBar(); 179 LocationBar* location_bar = GetLocationBar();
180 OmniboxView* omnibox_view = location_bar->GetOmniboxView(); 180 OmniboxView* omnibox_view = location_bar->GetOmniboxView();
181 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); 181 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText());
182 omnibox_view->SetUserText(string16()); 182 omnibox_view->SetUserText(base::string16());
183 content::WindowedNotificationObserver observer( 183 content::WindowedNotificationObserver observer(
184 content::NOTIFICATION_LOAD_STOP, 184 content::NOTIFICATION_LOAD_STOP,
185 content::NotificationService::AllSources()); 185 content::NotificationService::AllSources());
186 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL), 186 chrome::AddSelectedTabWithURL(browser(), GURL(content::kAboutBlankURL),
187 content::PAGE_TRANSITION_AUTO_TOPLEVEL); 187 content::PAGE_TRANSITION_AUTO_TOPLEVEL);
188 observer.Wait(); 188 observer.Wait();
189 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); 189 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText());
190 chrome::CloseTab(browser()); 190 chrome::CloseTab(browser());
191 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText()); 191 EXPECT_EQ(UTF8ToUTF16(content::kAboutBlankURL), omnibox_view->GetText());
192 EXPECT_TRUE(omnibox_view->IsSelectAll()); 192 EXPECT_TRUE(omnibox_view->IsSelectAll());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 location_bar->FocusSearch(); 277 location_bar->FocusSearch();
278 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid()); 278 EXPECT_FALSE(location_bar->GetDestinationURL().is_valid());
279 EXPECT_EQ(ASCIIToUTF16(" ?foo"), omnibox_view->GetText()); 279 EXPECT_EQ(ASCIIToUTF16(" ?foo"), omnibox_view->GetText());
280 280
281 size_t selection_start, selection_end; 281 size_t selection_start, selection_end;
282 omnibox_view->GetSelectionBounds(&selection_start, &selection_end); 282 omnibox_view->GetSelectionBounds(&selection_start, &selection_end);
283 EXPECT_EQ(4U, std::min(selection_start, selection_end)); 283 EXPECT_EQ(4U, std::min(selection_start, selection_end));
284 EXPECT_EQ(7U, std::max(selection_start, selection_end)); 284 EXPECT_EQ(7U, std::max(selection_start, selection_end));
285 } 285 }
286 } 286 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/web_view_interactive_browsertest.cc ('k') | chrome/browser/autocomplete/autocomplete_classifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698