Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/renderer_context_menu/spelling_menu_observer.h" | 5 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, item.command_id); | 317 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, item.command_id); |
| 318 EXPECT_TRUE(item.enabled); | 318 EXPECT_TRUE(item.enabled); |
| 319 EXPECT_TRUE(item.checked); | 319 EXPECT_TRUE(item.checked); |
| 320 EXPECT_FALSE(item.hidden); | 320 EXPECT_FALSE(item.hidden); |
| 321 } | 321 } |
| 322 | 322 |
| 323 // Test that there will be a separator after "no suggestions" if | 323 // Test that there will be a separator after "no suggestions" if |
| 324 // SpellingServiceClient::SUGGEST is on. | 324 // SpellingServiceClient::SUGGEST is on. |
| 325 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SeparatorAfterSuggestions) { | 325 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SeparatorAfterSuggestions) { |
| 326 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 326 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 327 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 328 command_line->AppendSwitch(switches::kUseSpellingSuggestions); | |
| 329 | 327 |
| 330 // Force a non-empty locale so SUGGEST is available. | 328 // Force a non-empty and non-"en" locale so SUGGEST is available. |
|
groby-ooo-7-16
2014/04/28 22:52:30
Since we're forcing "fr" in two places now, I'd s
please use gerrit instead
2014/04/29 03:11:33
Done.
| |
| 331 menu()->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en"); | 329 menu()->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "fr"); |
| 332 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu()->GetProfile(), | 330 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu()->GetProfile(), |
| 333 SpellingServiceClient::SUGGEST)); | 331 SpellingServiceClient::SUGGEST)); |
| 334 | 332 |
| 335 InitMenu("jhhj", NULL); | 333 InitMenu("jhhj", NULL); |
| 336 | 334 |
| 337 // The test should see a top separator, "No spelling suggestions", | 335 // The test should see a top separator, "No spelling suggestions", |
| 338 // "No more Google suggestions" (from SpellingService) and a separator | 336 // "No more Google suggestions" (from SpellingService) and a separator |
| 339 // as the first four items, then possibly more (not relevant here). | 337 // as the first four items, then possibly more (not relevant here). |
| 340 EXPECT_LT(4U, menu()->GetMenuSize()); | 338 EXPECT_LT(4U, menu()->GetMenuSize()); |
| 341 | 339 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 | 459 |
| 462 // Expect at least separator and 4 default entries. | 460 // Expect at least separator and 4 default entries. |
| 463 EXPECT_LT(static_cast<size_t>(5), menu()->GetMenuSize()); | 461 EXPECT_LT(static_cast<size_t>(5), menu()->GetMenuSize()); |
| 464 // This test only cares that the first one is a separator. | 462 // This test only cares that the first one is a separator. |
| 465 menu()->GetMenuItem(0, &item); | 463 menu()->GetMenuItem(0, &item); |
| 466 EXPECT_EQ(-1, item.command_id); | 464 EXPECT_EQ(-1, item.command_id); |
| 467 | 465 |
| 468 // Case #3. Misspelled word, suggestion service is on. | 466 // Case #3. Misspelled word, suggestion service is on. |
| 469 Reset(false); | 467 Reset(false); |
| 470 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 468 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 471 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 469 menu()->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "fr"); |
|
groby-ooo-7-16
2014/04/28 22:52:30
See above re: "fr"
please use gerrit instead
2014/04/29 03:11:33
Done.
| |
| 472 command_line->AppendSwitch(switches::kUseSpellingSuggestions); | |
| 473 InitMenu("asdfkj", NULL); | 470 InitMenu("asdfkj", NULL); |
| 474 | 471 |
| 475 // Should have at least 2 entries. Separator, suggestion. | 472 // Should have at least 2 entries. Separator, suggestion. |
| 476 EXPECT_LT(2U, menu()->GetMenuSize()); | 473 EXPECT_LT(2U, menu()->GetMenuSize()); |
| 477 menu()->GetMenuItem(0, &item); | 474 menu()->GetMenuItem(0, &item); |
| 478 EXPECT_EQ(-1, item.command_id); | 475 EXPECT_EQ(-1, item.command_id); |
| 479 menu()->GetMenuItem(1, &item); | 476 menu()->GetMenuItem(1, &item); |
| 480 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); | 477 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); |
| 481 } | 478 } |
| OLD | NEW |