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

Side by Side Diff: chrome/test/ui/omnibox_uitest.cc

Issue 6306011: Remove wstring from autocomplete. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
Property Changes:
Deleted: svn:mergeinfo
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 <math.h> 5 #include <math.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 time_squared_ = 0; 45 time_squared_ = 0;
46 time_sum_ = 0; 46 time_sum_ = 0;
47 time_min_ = 0; 47 time_min_ = 0;
48 time_max_ = 0; 48 time_max_ = 0;
49 } 49 }
50 50
51 // Many times a user may enter something like "google.com". If 51 // Many times a user may enter something like "google.com". If
52 // http://www.google.com/ is suggested that should be considered a match. 52 // http://www.google.com/ is suggested that should be considered a match.
53 // This could probably be accomplished with regex as well. Note that this 53 // This could probably be accomplished with regex as well. Note that this
54 // method is called even when suggestion isn't a URL. 54 // method is called even when suggestion isn't a URL.
55 bool IsMatch(const std::wstring& input_test, const std::wstring& suggestion); 55 bool IsMatch(const string16& input_test, const string16& suggestion);
56 // Runs a query chain. This sends each proper prefix of the input to the 56 // Runs a query chain. This sends each proper prefix of the input to the
57 // omnibox and scores the autocompelte results returned. 57 // omnibox and scores the autocompelte results returned.
58 void RunQueryChain(const std::wstring& input_text); 58 void RunQueryChain(const string16& input_text);
59 }; 59 };
60 60
61 bool OmniboxTest::IsMatch(const std::wstring& input_text, 61 bool OmniboxTest::IsMatch(const string16& input_text,
62 const std::wstring& suggestion) { 62 const string16& suggestion) {
63 // This prefix list comes from the list used in history_url_provider.cc 63 // This prefix list comes from the list used in history_url_provider.cc
64 // with the exception of "ftp." and "www.". 64 // with the exception of "ftp." and "www.".
65 std::wstring prefixes[] = {L"", L"ftp://", L"http://", L"https://", 65 string16 prefixes[] = {ASCIIToUTF16(""), ASCIIToUTF16("ftp://"),
66 L"ftp.", L"www.", L"ftp://www.", L"ftp://ftp.", 66 ASCIIToUTF16("http://"), ASCIIToUTF16("https://"), ASCIIToUTF16("ftp."),
67 L"http://www.", L"https://www."}; 67 ASCIIToUTF16("www."), ASCIIToUTF16("ftp://www."),
68 std::wstring postfixes[] = {L"", L"/"}; 68 ASCIIToUTF16("ftp://ftp."), ASCIIToUTF16("http://www."),
69 ASCIIToUTF16("https://www.")};
70 string16 postfixes[] = {ASCIIToUTF16(""), ASCIIToUTF16("/")};
69 for (size_t i = 0; i < arraysize(prefixes); ++i) { 71 for (size_t i = 0; i < arraysize(prefixes); ++i) {
70 for (size_t j = 0; j < arraysize(postfixes); ++j) { 72 for (size_t j = 0; j < arraysize(postfixes); ++j) {
71 if (prefixes[i] + input_text + postfixes[j] == suggestion) 73 if (prefixes[i] + input_text + postfixes[j] == suggestion)
72 return true; 74 return true;
73 } 75 }
74 } 76 }
75 return false; 77 return false;
76 } 78 }
77 79
78 void OmniboxTest::RunQueryChain(const std::wstring& input_text) { 80 void OmniboxTest::RunQueryChain(const string16& input_text) {
79 // Get a handle on the omnibox and give it focus. 81 // Get a handle on the omnibox and give it focus.
80 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 82 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
81 ASSERT_TRUE(browser.get()); 83 ASSERT_TRUE(browser.get());
82 scoped_refptr<WindowProxy> window(browser->GetWindow()); 84 scoped_refptr<WindowProxy> window(browser->GetWindow());
83 ASSERT_TRUE(window.get()); 85 ASSERT_TRUE(window.get());
84 scoped_refptr<AutocompleteEditProxy> autocomplete_edit( 86 scoped_refptr<AutocompleteEditProxy> autocomplete_edit(
85 browser->GetAutocompleteEdit()); 87 browser->GetAutocompleteEdit());
86 ASSERT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); 88 ASSERT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION));
87 89
88 // Try every proper prefix of input_text. There's no use trying 90 // Try every proper prefix of input_text. There's no use trying
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 std::vector<std::string> expected_providers; 158 std::vector<std::string> expected_providers;
157 ASSERT_TRUE(reader.NodeAttribute("query", &query)); 159 ASSERT_TRUE(reader.NodeAttribute("query", &query));
158 reader.Read(); 160 reader.Read();
159 while (reader.SkipToElement()) { 161 while (reader.SkipToElement()) {
160 ASSERT_EQ("provider", reader.NodeName()); 162 ASSERT_EQ("provider", reader.NodeName());
161 std::string provider; 163 std::string provider;
162 ASSERT_TRUE(reader.NodeAttribute("provider", &provider)); 164 ASSERT_TRUE(reader.NodeAttribute("provider", &provider));
163 expected_providers.push_back(provider); 165 expected_providers.push_back(provider);
164 reader.Read(); 166 reader.Read();
165 } 167 }
166 RunQueryChain(ASCIIToWide(query)); 168 RunQueryChain(ASCIIToUTF16(query));
167 reader.Read(); 169 reader.Read();
168 } 170 }
169 reader.Read(); 171 reader.Read();
170 } 172 }
171 173
172 // Output results. 174 // Output results.
173 ASSERT_GT(query_count_, 0); 175 ASSERT_GT(query_count_, 0);
174 int64 mean = time_sum_ / query_count_; 176 int64 mean = time_sum_ / query_count_;
175 wprintf(L"__om_query_count = %d\n", query_count_); 177 wprintf(L"__om_query_count = %d\n", query_count_);
176 wprintf(L"__om_query_timeouts = %d\n", query_timeouts_); 178 wprintf(L"__om_query_timeouts = %d\n", query_timeouts_);
177 wprintf(L"__om_time_per_query_avg = %d\n", mean); 179 wprintf(L"__om_time_per_query_avg = %d\n", mean);
178 // Use the equation stddev = sqrt(Sum(x_i^2)/N - mean^2). 180 // Use the equation stddev = sqrt(Sum(x_i^2)/N - mean^2).
179 wprintf(L"__om_time_per_query_stddev = %d\n", static_cast<int64>( 181 wprintf(L"__om_time_per_query_stddev = %d\n", static_cast<int64>(
180 sqrt(1.0 * time_squared_ / query_count_ - mean * mean))); 182 sqrt(1.0 * time_squared_ / query_count_ - mean * mean)));
181 wprintf(L"__om_time_per_query_max = %d\n", time_max_); 183 wprintf(L"__om_time_per_query_max = %d\n", time_max_);
182 wprintf(L"__om_time_per_query_min = %d\n", time_min_); 184 wprintf(L"__om_time_per_query_min = %d\n", time_min_);
183 wprintf(L"__om_score = %.4f\n", 100.0 * score_ / max_score_); 185 wprintf(L"__om_score = %.4f\n", 100.0 * score_ / max_score_);
184 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698