| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 " }\n" | 256 " }\n" |
| 257 "}", | 257 "}", |
| 258 true, | 258 true, |
| 259 "I have been to USA.", | 259 "I have been to USA.", |
| 260 }, | 260 }, |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 PrefService* pref = profile_.GetPrefs(); | 263 PrefService* pref = profile_.GetPrefs(); |
| 264 pref->SetBoolean(prefs::kEnableSpellCheck, true); | 264 pref->SetBoolean(prefs::kEnableSpellCheck, true); |
| 265 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 265 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 266 pref->SetString(prefs::kSpellCheckDictionary, ""); |
| 266 | 267 |
| 267 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { | 268 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { |
| 268 client_.SetHTTPRequest(kTests[i].request_type, kTests[i].request_text); | 269 client_.SetHTTPRequest(kTests[i].request_type, kTests[i].request_text); |
| 269 client_.SetHTTPResponse(kTests[i].response_status, kTests[i].response_data); | 270 client_.SetHTTPResponse(kTests[i].response_status, kTests[i].response_data); |
| 270 client_.SetExpectedTextCheckResult(kTests[i].success, | 271 client_.SetExpectedTextCheckResult(kTests[i].success, |
| 271 kTests[i].corrected_text); | 272 kTests[i].corrected_text); |
| 272 client_.RequestTextCheck( | 273 client_.RequestTextCheck( |
| 273 &profile_, | 274 &profile_, |
| 274 0, | 275 0, |
| 275 kTests[i].request_type, | 276 kTests[i].request_type, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 297 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); | 298 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); |
| 298 | 299 |
| 299 pref->SetBoolean(prefs::kEnableSpellCheck, true); | 300 pref->SetBoolean(prefs::kEnableSpellCheck, true); |
| 300 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 301 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 301 | 302 |
| 302 // For locales supported by the SpellCheck service, this function returns | 303 // For locales supported by the SpellCheck service, this function returns |
| 303 // false for suggestions and true for spellcheck. (The comment in | 304 // false for suggestions and true for spellcheck. (The comment in |
| 304 // SpellingServiceClient::IsAvailable() describes why this function returns | 305 // SpellingServiceClient::IsAvailable() describes why this function returns |
| 305 // false for suggestions.) | 306 // false for suggestions.) |
| 306 static const char* kSupported[] = { | 307 static const char* kSupported[] = { |
| 307 "", "en-AU", "en-CA", "en-GB", "en-US", | 308 "", |
| 309 #if !defined(OS_MACOSX) |
| 310 "en-AU", "en-CA", "en-GB", "en-US", |
| 311 #endif |
| 308 }; | 312 }; |
| 309 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupported); ++i) { | 313 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupported); ++i) { |
| 310 pref->SetString(prefs::kSpellCheckDictionary, kSupported[i]); | 314 pref->SetString(prefs::kSpellCheckDictionary, kSupported[i]); |
| 311 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest)); | 315 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest)); |
| 312 EXPECT_TRUE(client_.IsAvailable(&profile_, kSpellcheck)); | 316 EXPECT_TRUE(client_.IsAvailable(&profile_, kSpellcheck)); |
| 313 } | 317 } |
| 314 | 318 |
| 315 // On the other hand, this function returns true for suggestions and false for | 319 // On the other hand, this function returns true for suggestions and false for |
| 316 // spellcheck for unsupported locales. | 320 // spellcheck for unsupported locales. |
| 317 static const char* kUnsupported[] = { | 321 static const char* kUnsupported[] = { |
| 322 #if defined(OS_MACOSX) |
| 323 "en-AU", "en-CA", "en-GB", "en-US", |
| 324 #endif |
| 318 "af-ZA", "bg-BG", "ca-ES", "cs-CZ", "da-DK", "de-DE", "el-GR", "es-ES", | 325 "af-ZA", "bg-BG", "ca-ES", "cs-CZ", "da-DK", "de-DE", "el-GR", "es-ES", |
| 319 "et-EE", "fo-FO", "fr-FR", "he-IL", "hi-IN", "hr-HR", "hu-HU", "id-ID", | 326 "et-EE", "fo-FO", "fr-FR", "he-IL", "hi-IN", "hr-HR", "hu-HU", "id-ID", |
| 320 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", | 327 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", |
| 321 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", | 328 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", |
| 322 "uk-UA", "vi-VN", | 329 "uk-UA", "vi-VN", |
| 323 }; | 330 }; |
| 324 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { | 331 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { |
| 325 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); | 332 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); |
| 326 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); | 333 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); |
| 327 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); | 334 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); |
| 328 } | 335 } |
| 329 } | 336 } |
| OLD | NEW |