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

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

Issue 647753003: Make ARRAYSIZE_UNSAFE() just use arraysize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added bug 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 // For locales supported by the SpellCheck service, this function returns 343 // For locales supported by the SpellCheck service, this function returns
344 // false for suggestions and true for spellcheck. (The comment in 344 // false for suggestions and true for spellcheck. (The comment in
345 // SpellingServiceClient::IsAvailable() describes why this function returns 345 // SpellingServiceClient::IsAvailable() describes why this function returns
346 // false for suggestions.) If there is no language set, then we 346 // false for suggestions.) If there is no language set, then we
347 // do not allow any remote. 347 // do not allow any remote.
348 pref->SetString(prefs::kSpellCheckDictionary, std::string()); 348 pref->SetString(prefs::kSpellCheckDictionary, std::string());
349 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest)); 349 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest));
350 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 350 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
351 351
352 #if !defined(OS_MACOSX)
352 static const char* kSupported[] = { 353 static const char* kSupported[] = {
353 #if !defined(OS_MACOSX)
354 "en-AU", "en-CA", "en-GB", "en-US", 354 "en-AU", "en-CA", "en-GB", "en-US",
355 #endif
356 }; 355 };
357 // If spellcheck is allowed, then suggest is not since spellcheck is a 356 // If spellcheck is allowed, then suggest is not since spellcheck is a
358 // superset of suggest. 357 // superset of suggest.
359 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupported); ++i) { 358 for (size_t i = 0; i < arraysize(kSupported); ++i) {
360 pref->SetString(prefs::kSpellCheckDictionary, kSupported[i]); 359 pref->SetString(prefs::kSpellCheckDictionary, kSupported[i]);
361 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest)); 360 EXPECT_FALSE(client_.IsAvailable(&profile_, kSuggest));
362 EXPECT_TRUE(client_.IsAvailable(&profile_, kSpellcheck)); 361 EXPECT_TRUE(client_.IsAvailable(&profile_, kSpellcheck));
363 } 362 }
364 363
365 // This function returns true for suggestions for all and false for 364 // This function returns true for suggestions for all and false for
366 // spellcheck for unsupported locales. 365 // spellcheck for unsupported locales.
367 static const char* kUnsupported[] = { 366 static const char* kUnsupported[] = {
368 #if !defined(OS_MACOSX)
369 "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",
370 "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",
371 "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",
372 "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",
373 "uk-UA", "vi-VN", 371 "uk-UA", "vi-VN",
374 #endif
375 }; 372 };
376 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) { 373 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kUnsupported); ++i) {
377 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]); 374 pref->SetString(prefs::kSpellCheckDictionary, kUnsupported[i]);
378 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest)); 375 EXPECT_TRUE(client_.IsAvailable(&profile_, kSuggest));
379 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck)); 376 EXPECT_FALSE(client_.IsAvailable(&profile_, kSpellcheck));
380 } 377 }
378 #endif // !defined(OS_MACOSX)
381 } 379 }
382 380
383 // 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
384 // ParseResponse returning false. 382 // ParseResponse returning false.
385 TEST_F(SpellingServiceClientTest, ResponseErrorTest) { 383 TEST_F(SpellingServiceClientTest, ResponseErrorTest) {
386 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}")); 384 EXPECT_TRUE(client_.ParseResponseSuccess("{\"result\": {}}"));
387 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}")); 385 EXPECT_FALSE(client_.ParseResponseSuccess("{\"error\": {}}"));
388 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698