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

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

Issue 11414303: Make Google Search autocomplete provider cursor aware. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autocomplete/autocomplete_match.h" 8 #include "chrome/browser/autocomplete/autocomplete_match.h"
9 #include "chrome/browser/autocomplete/extension_app_provider.h" 9 #include "chrome/browser/autocomplete/extension_app_provider.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 info.set_typed_count(kExtensionApps[i].typed_count); 79 info.set_typed_count(kExtensionApps[i].typed_count);
80 url_db->AddURL(info); 80 url_db->AddURL(info);
81 } 81 }
82 } 82 }
83 83
84 void ExtensionAppProviderTest::RunTest( 84 void ExtensionAppProviderTest::RunTest(
85 test_data* keyword_cases, 85 test_data* keyword_cases,
86 int num_cases) { 86 int num_cases) {
87 ACMatches matches; 87 ACMatches matches;
88 for (int i = 0; i < num_cases; ++i) { 88 for (int i = 0; i < num_cases; ++i) {
89 AutocompleteInput input(keyword_cases[i].input, string16(), true, 89 AutocompleteInput input(keyword_cases[i].input, string16::npos, string16(),
90 false, true, AutocompleteInput::ALL_MATCHES); 90 true, false, true, AutocompleteInput::ALL_MATCHES);
91 app_provider_->Start(input, false); 91 app_provider_->Start(input, false);
92 EXPECT_TRUE(app_provider_->done()); 92 EXPECT_TRUE(app_provider_->done());
93 matches = app_provider_->matches(); 93 matches = app_provider_->matches();
94 EXPECT_EQ(keyword_cases[i].num_results, matches.size()) 94 EXPECT_EQ(keyword_cases[i].num_results, matches.size())
95 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input; 95 << ASCIIToUTF16("Input was: ") + keyword_cases[i].input;
96 if (matches.size() == keyword_cases[i].num_results) { 96 if (matches.size() == keyword_cases[i].num_results) {
97 for (size_t j = 0; j < keyword_cases[i].num_results; ++j) 97 for (size_t j = 0; j < keyword_cases[i].num_results; ++j)
98 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url); 98 EXPECT_EQ(keyword_cases[i].output[j], matches[j].destination_url);
99 } 99 }
100 } 100 }
(...skipping 27 matching lines...) Expand all
128 TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) { 128 TEST_F(ExtensionAppProviderTest, CreateMatchSanitize) {
129 struct TestData { 129 struct TestData {
130 const char* name; 130 const char* name;
131 const char* match_contents; 131 const char* match_contents;
132 } cases[] = { 132 } cases[] = {
133 { "Test", "Test" }, 133 { "Test", "Test" },
134 { "Test \n Test", "Test Test" }, 134 { "Test \n Test", "Test Test" },
135 { "Test\r\t\nTest", "TestTest" }, 135 { "Test\r\t\nTest", "TestTest" },
136 }; 136 };
137 137
138 AutocompleteInput input(ASCIIToUTF16("Test"), string16(), 138 AutocompleteInput input(ASCIIToUTF16("Test"), string16::npos, string16(),
139 true, true, true, AutocompleteInput::BEST_MATCH); 139 true, true, true, AutocompleteInput::BEST_MATCH);
140 string16 url(ASCIIToUTF16("http://example.com")); 140 string16 url(ASCIIToUTF16("http://example.com"));
141 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { 141 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
142 ExtensionAppProvider::ExtensionApp extension_app = 142 ExtensionAppProvider::ExtensionApp extension_app =
143 {ASCIIToUTF16(cases[i].name), url, true}; 143 {ASCIIToUTF16(cases[i].name), url, true};
144 AutocompleteMatch match = 144 AutocompleteMatch match =
145 app_provider_->CreateAutocompleteMatch(input, 145 app_provider_->CreateAutocompleteMatch(input,
146 extension_app, 146 extension_app,
147 0, 147 0,
148 string16::npos); 148 string16::npos);
149 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents); 149 EXPECT_EQ(ASCIIToUTF16(cases[i].match_contents), match.contents);
150 } 150 }
151 } 151 }
152
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698