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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client_unittest.cc

Issue 11151023: Merge 161535 - Fix the spelling client not to use the spelling service yet. Also disabling some tes… (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 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
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Verifies that SpellingServiceClient::RequestTextCheck() creates a JSON 204 // Verifies that SpellingServiceClient::RequestTextCheck() creates a JSON
205 // request sent to the Spelling service as we expect. This test also verifies 205 // request sent to the Spelling service as we expect. This test also verifies
206 // that it parses a JSON response from the service and calls the callback 206 // that it parses a JSON response from the service and calls the callback
207 // function. To avoid sending JSON-RPC requests to the service, this test uses a 207 // function. To avoid sending JSON-RPC requests to the service, this test uses a
208 // custom TestURLFecher class (TestSpellingURLFetcher) which calls 208 // custom TestURLFecher class (TestSpellingURLFetcher) which calls
209 // SpellingServiceClient::OnURLFetchComplete() with the parameters set by this 209 // SpellingServiceClient::OnURLFetchComplete() with the parameters set by this
210 // test. This test also uses a custom callback function that replaces all 210 // test. This test also uses a custom callback function that replaces all
211 // misspelled words with ones suggested by the service so this test can compare 211 // misspelled words with ones suggested by the service so this test can compare
212 // the corrected text with the expected results. (If there are not any 212 // the corrected text with the expected results. (If there are not any
213 // misspelled words, |corrected_text| should be equal to |request_text|.) 213 // misspelled words, |corrected_text| should be equal to |request_text|.)
214 TEST_F(SpellingServiceClientTest, RequestTextCheck) { 214 TEST_F(SpellingServiceClientTest, DISABLED_RequestTextCheck) {
215 static const struct { 215 static const struct {
216 const char* request_text; 216 const char* request_text;
217 SpellingServiceClient::ServiceType request_type; 217 SpellingServiceClient::ServiceType request_type;
218 int response_status; 218 int response_status;
219 const char* response_data; 219 const char* response_data;
220 bool success; 220 bool success;
221 const char* corrected_text; 221 const char* corrected_text;
222 const char* language; 222 const char* language;
223 } kTests[] = { 223 } kTests[] = {
224 { 224 {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 kTests[i].request_type, 311 kTests[i].request_type,
312 ASCIIToUTF16(kTests[i].request_text), 312 ASCIIToUTF16(kTests[i].request_text),
313 base::Bind(&SpellingServiceClientTest::OnTextCheckComplete, 313 base::Bind(&SpellingServiceClientTest::OnTextCheckComplete,
314 base::Unretained(this))); 314 base::Unretained(this)));
315 client_.CallOnURLFetchComplete(); 315 client_.CallOnURLFetchComplete();
316 } 316 }
317 } 317 }
318 318
319 // Verify that SpellingServiceClient::IsAvailable() returns true only when it 319 // Verify that SpellingServiceClient::IsAvailable() returns true only when it
320 // can send suggest requests or spellcheck requests. 320 // can send suggest requests or spellcheck requests.
321 TEST_F(SpellingServiceClientTest, AvailableServices) { 321 TEST_F(SpellingServiceClientTest, DISABLED_AvailableServices) {
322 const SpellingServiceClient::ServiceType kSuggest = 322 const SpellingServiceClient::ServiceType kSuggest =
323 SpellingServiceClient::SUGGEST; 323 SpellingServiceClient::SUGGEST;
324 const SpellingServiceClient::ServiceType kSpellcheck = 324 const SpellingServiceClient::ServiceType kSpellcheck =
325 SpellingServiceClient::SPELLCHECK; 325 SpellingServiceClient::SPELLCHECK;
326 326
327 // When a user disables spellchecking or prevent using the Spelling service, 327 // When a user disables spellchecking or prevent using the Spelling service,
328 // this function should return false both for suggestions and for spellcheck. 328 // this function should return false both for suggestions and for spellcheck.
329 PrefService* pref = profile_.GetPrefs(); 329 PrefService* pref = profile_.GetPrefs();
330 pref->SetBoolean(prefs::kEnableSpellCheck, false); 330 pref->SetBoolean(prefs::kEnableSpellCheck, false);
331 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, false); 331 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, false);
(...skipping 30 matching lines...) Expand all
362 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", 362 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT",
363 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", 363 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR",
364 "uk-UA", "vi-VN", 364 "uk-UA", "vi-VN",
365 }; 365 };
366 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { 366 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) {
367 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); 367 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]);
368 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); 368 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest));
369 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 369 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
370 } 370 }
371 } 371 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698