| 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 "chrome/browser/tab_contents/spelling_menu_observer.h" | 5 #include "chrome/browser/tab_contents/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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Test that there will be a separator after "no suggestions" if | 322 // Test that there will be a separator after "no suggestions" if |
| 323 // SpellingServiceClient::SUGGEST is on. | 323 // SpellingServiceClient::SUGGEST is on. |
| 324 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SeparatorAfterSuggestions) { | 324 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SeparatorAfterSuggestions) { |
| 325 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); | 325 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); |
| 326 scoped_ptr<SpellingMenuObserver> observer( | 326 scoped_ptr<SpellingMenuObserver> observer( |
| 327 new SpellingMenuObserver(menu.get())); | 327 new SpellingMenuObserver(menu.get())); |
| 328 menu->SetObserver(observer.get()); | 328 menu->SetObserver(observer.get()); |
| 329 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 329 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 330 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 331 command_line->AppendSwitch(switches::kUseSpellingSuggestions); |
| 330 | 332 |
| 331 // Make sure we can pretend to handle the JSON request. | 333 // Make sure we can pretend to handle the JSON request. |
| 332 menu->CreateRequestContext(); | 334 menu->CreateRequestContext(); |
| 333 | 335 |
| 334 // Force a non-empty locale so SUGGEST is available. | 336 // Force a non-empty locale so SUGGEST is available. |
| 335 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en"); | 337 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en"); |
| 336 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu->GetProfile(), | 338 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu->GetProfile(), |
| 337 SpellingServiceClient::SUGGEST)); | 339 SpellingServiceClient::SUGGEST)); |
| 338 | 340 |
| 339 content::ContextMenuParams params; | 341 content::ContextMenuParams params; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 365 | 367 |
| 366 // Test that we don't show "No more suggestions from Google" if the spelling | 368 // Test that we don't show "No more suggestions from Google" if the spelling |
| 367 // service is enabled and that there is only one suggestion. | 369 // service is enabled and that there is only one suggestion. |
| 368 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, | 370 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, |
| 369 NoMoreSuggestionsNotDisplayed) { | 371 NoMoreSuggestionsNotDisplayed) { |
| 370 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); | 372 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); |
| 371 scoped_ptr<SpellingMenuObserver> observer( | 373 scoped_ptr<SpellingMenuObserver> observer( |
| 372 new SpellingMenuObserver(menu.get())); | 374 new SpellingMenuObserver(menu.get())); |
| 373 menu->SetObserver(observer.get()); | 375 menu->SetObserver(observer.get()); |
| 374 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 376 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 375 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 376 command_line->AppendSwitch(switches::kUseSpellingService); | |
| 377 | 377 |
| 378 // Make sure we can pretend to handle the JSON request. | 378 // Make sure we can pretend to handle the JSON request. |
| 379 menu->CreateRequestContext(); | 379 menu->CreateRequestContext(); |
| 380 | 380 |
| 381 // Force a non-empty locale so SPELLCHECK is available. | 381 // Force a non-empty locale so SPELLCHECK is available. |
| 382 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en"); | 382 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "en"); |
| 383 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu->GetProfile(), | 383 EXPECT_TRUE(SpellingServiceClient::IsAvailable(menu->GetProfile(), |
| 384 SpellingServiceClient::SPELLCHECK)); | 384 SpellingServiceClient::SPELLCHECK)); |
| 385 | 385 |
| 386 content::ContextMenuParams params; | 386 content::ContextMenuParams params; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 398 EXPECT_EQ(IDC_SPELLCHECK_SUGGESTION_0, item.command_id); | 398 EXPECT_EQ(IDC_SPELLCHECK_SUGGESTION_0, item.command_id); |
| 399 EXPECT_TRUE(item.enabled); | 399 EXPECT_TRUE(item.enabled); |
| 400 EXPECT_FALSE(item.hidden); | 400 EXPECT_FALSE(item.hidden); |
| 401 | 401 |
| 402 menu->GetMenuItem(1, &item); | 402 menu->GetMenuItem(1, &item); |
| 403 EXPECT_NE(IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS, item.command_id); | 403 EXPECT_NE(IDC_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS, item.command_id); |
| 404 EXPECT_EQ(-1, item.command_id); | 404 EXPECT_EQ(-1, item.command_id); |
| 405 EXPECT_FALSE(item.enabled); | 405 EXPECT_FALSE(item.enabled); |
| 406 EXPECT_FALSE(item.hidden); | 406 EXPECT_FALSE(item.hidden); |
| 407 } | 407 } |
| OLD | NEW |