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

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

Issue 655413002: Convert ARRAYSIZE_UNSAFE -> arraysize in chrome/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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/bind.h" 8 #include "base/bind.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 private: 89 private:
90 bool GetExpectedCountry(const std::string& language, std::string* country) { 90 bool GetExpectedCountry(const std::string& language, std::string* country) {
91 static const struct { 91 static const struct {
92 const char* language; 92 const char* language;
93 const char* country; 93 const char* country;
94 } kCountries[] = { 94 } kCountries[] = {
95 {"af", "ZAF"}, 95 {"af", "ZAF"},
96 {"en", "USA"}, 96 {"en", "USA"},
97 }; 97 };
98 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kCountries); ++i) { 98 for (size_t i = 0; i < arraysize(kCountries); ++i) {
99 if (!language.compare(kCountries[i].language)) { 99 if (!language.compare(kCountries[i].language)) {
100 country->assign(kCountries[i].country); 100 country->assign(kCountries[i].country);
101 return true; 101 return true;
102 } 102 }
103 } 103 }
104 return false; 104 return false;
105 } 105 }
106 106
107 std::string version_; 107 std::string version_;
108 std::string language_; 108 std::string language_;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 true, 297 true,
298 "I have been to USA.", 298 "I have been to USA.",
299 "en", 299 "en",
300 }, 300 },
301 }; 301 };
302 302
303 PrefService* pref = profile_.GetPrefs(); 303 PrefService* pref = profile_.GetPrefs();
304 pref->SetBoolean(prefs::kEnableContinuousSpellcheck, true); 304 pref->SetBoolean(prefs::kEnableContinuousSpellcheck, true);
305 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true); 305 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, true);
306 306
307 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTests); ++i) { 307 for (size_t i = 0; i < arraysize(kTests); ++i) {
308 client_.SetHTTPRequest(kTests[i].request_type, kTests[i].request_text, 308 client_.SetHTTPRequest(kTests[i].request_type, kTests[i].request_text,
309 kTests[i].language); 309 kTests[i].language);
310 client_.SetHTTPResponse(kTests[i].response_status, kTests[i].response_data); 310 client_.SetHTTPResponse(kTests[i].response_status, kTests[i].response_data);
311 client_.SetExpectedTextCheckResult(kTests[i].success, 311 client_.SetExpectedTextCheckResult(kTests[i].success,
312 kTests[i].corrected_text); 312 kTests[i].corrected_text);
313 pref->SetString(prefs::kSpellCheckDictionary, kTests[i].language); 313 pref->SetString(prefs::kSpellCheckDictionary, kTests[i].language);
314 client_.RequestTextCheck( 314 client_.RequestTextCheck(
315 &profile_, 315 &profile_,
316 kTests[i].request_type, 316 kTests[i].request_type,
317 base::ASCIIToUTF16(kTests[i].request_text), 317 base::ASCIIToUTF16(kTests[i].request_text),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 // This function returns true for suggestions for all and false for 364 // This function returns true for suggestions for all and false for
365 // spellcheck for unsupported locales. 365 // spellcheck for unsupported locales.
366 static const char* kUnsupported[] = { 366 static const char* kUnsupported[] = {
367 "af-ZA", "bg-BG", "ca-ES", "cs-CZ", "da-DK", "de-DE", "el-GR", "es-ES", 367 "af-ZA", "bg-BG", "ca-ES", "cs-CZ", "da-DK", "de-DE", "el-GR", "es-ES",
368 "et-EE", "fo-FO", "fr-FR", "he-IL", "hi-IN", "hr-HR", "hu-HU", "id-ID", 368 "et-EE", "fo-FO", "fr-FR", "he-IL", "hi-IN", "hr-HR", "hu-HU", "id-ID",
369 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", 369 "it-IT", "lt-LT", "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT",
370 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR", 370 "ro-RO", "ru-RU", "sk-SK", "sl-SI", "sh", "sr", "sv-SE", "tr-TR",
371 "uk-UA", "vi-VN", 371 "uk-UA", "vi-VN",
372 }; 372 };
373 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { 373 for (size_t i = 0; i < arraysize(kUnsupported); ++i) {
374 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); 374 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]);
375 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); 375 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest));
376 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 376 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
377 } 377 }
378 #endif // !defined(OS_MACOSX) 378 #endif // !defined(OS_MACOSX)
379 } 379 }
380 380
381 // Verify that an error in JSON response from spelling service will result in 381 // Verify that an error in JSON response from spelling service will result in
382 // ParseResponse returning false. 382 // ParseResponse returning false.
383 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { 383 TEST_F(SpellingServiceClientTest, ResponseErrorTest) {
384 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); 384 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}"));
385 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); 385 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}"));
386 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698