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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // Tests that right-clicking a misspelled word when we enable spelling-service | 294 // Tests that right-clicking a misspelled word when we enable spelling-service |
295 // integration to verify an item "Ask Google for suggestions" is checked. (This | 295 // integration to verify an item "Ask Google for suggestions" is checked. (This |
296 // test does not actually send JSON-RPC requests to the service because it makes | 296 // test does not actually send JSON-RPC requests to the service because it makes |
297 // this test flaky.) | 297 // this test flaky.) |
298 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, EnableSpellingService) { | 298 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, EnableSpellingService) { |
299 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); | 299 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); |
300 scoped_ptr<SpellingMenuObserver> observer( | 300 scoped_ptr<SpellingMenuObserver> observer( |
301 new SpellingMenuObserver(menu.get())); | 301 new SpellingMenuObserver(menu.get())); |
302 menu->SetObserver(observer.get()); | 302 menu->SetObserver(observer.get()); |
303 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 303 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
304 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, ""); | 304 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, std::string()); |
305 | 305 |
306 content::ContextMenuParams params; | 306 content::ContextMenuParams params; |
307 params.is_editable = true; | 307 params.is_editable = true; |
308 params.misspelled_word = ASCIIToUTF16("wiimode"); | 308 params.misspelled_word = ASCIIToUTF16("wiimode"); |
309 observer->InitMenu(params); | 309 observer->InitMenu(params); |
310 EXPECT_EQ(static_cast<size_t>(4), menu->GetMenuSize()); | 310 EXPECT_EQ(static_cast<size_t>(4), menu->GetMenuSize()); |
311 | 311 |
312 // To avoid duplicates, this test reads only the "Ask Google for suggestions" | 312 // To avoid duplicates, this test reads only the "Ask Google for suggestions" |
313 // item and verifies it is enabled and checked. | 313 // item and verifies it is enabled and checked. |
314 MockRenderViewContextMenu::MockMenuItem item; | 314 MockRenderViewContextMenu::MockMenuItem item; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 menu->CreateRequestContext(); | 525 menu->CreateRequestContext(); |
526 observer->InitMenu(params); | 526 observer->InitMenu(params); |
527 | 527 |
528 // Should have at least 2 entries. Separator, suggestion. | 528 // Should have at least 2 entries. Separator, suggestion. |
529 EXPECT_LT(2U, menu->GetMenuSize()); | 529 EXPECT_LT(2U, menu->GetMenuSize()); |
530 menu->GetMenuItem(0, &item); | 530 menu->GetMenuItem(0, &item); |
531 EXPECT_EQ(-1, item.command_id); | 531 EXPECT_EQ(-1, item.command_id); |
532 menu->GetMenuItem(1, &item); | 532 menu->GetMenuItem(1, &item); |
533 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); | 533 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); |
534 } | 534 } |
OLD | NEW |