| 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Tests that right-clicking a misspelled word when we enable spelling-service | 286 // Tests that right-clicking a misspelled word when we enable spelling-service |
| 287 // integration to verify an item "Ask Google for suggestions" is checked. (This | 287 // integration to verify an item "Ask Google for suggestions" is checked. (This |
| 288 // test does not actually send JSON-RPC requests to the service because it makes | 288 // test does not actually send JSON-RPC requests to the service because it makes |
| 289 // this test flaky.) | 289 // this test flaky.) |
| 290 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, EnableSpellingService) { | 290 IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, EnableSpellingService) { |
| 291 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); | 291 scoped_ptr<MockRenderViewContextMenu> menu(new MockRenderViewContextMenu); |
| 292 scoped_ptr<SpellingMenuObserver> observer( | 292 scoped_ptr<SpellingMenuObserver> observer( |
| 293 new SpellingMenuObserver(menu.get())); | 293 new SpellingMenuObserver(menu.get())); |
| 294 menu->SetObserver(observer.get()); | 294 menu->SetObserver(observer.get()); |
| 295 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 295 menu->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 296 menu->GetPrefs()->SetString(prefs::kSpellCheckDictionary, ""); |
| 296 | 297 |
| 297 content::ContextMenuParams params; | 298 content::ContextMenuParams params; |
| 298 params.is_editable = true; | 299 params.is_editable = true; |
| 299 params.misspelled_word = ASCIIToUTF16("wiimode"); | 300 params.misspelled_word = ASCIIToUTF16("wiimode"); |
| 300 observer->InitMenu(params); | 301 observer->InitMenu(params); |
| 301 EXPECT_EQ(static_cast<size_t>(4), menu->GetMenuSize()); | 302 EXPECT_EQ(static_cast<size_t>(4), menu->GetMenuSize()); |
| 302 | 303 |
| 303 // To avoid duplicates, this test reads only the "Ask Google for suggestions" | 304 // To avoid duplicates, this test reads only the "Ask Google for suggestions" |
| 304 // item and verifies it is enabled and checked. | 305 // item and verifies it is enabled and checked. |
| 305 MockRenderViewContextMenu::MockMenuItem item; | 306 MockRenderViewContextMenu::MockMenuItem item; |
| 306 menu->GetMenuItem(2, &item); | 307 menu->GetMenuItem(2, &item); |
| 307 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, item.command_id); | 308 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, item.command_id); |
| 308 EXPECT_TRUE(item.enabled); | 309 EXPECT_TRUE(item.enabled); |
| 309 EXPECT_TRUE(item.checked); | 310 EXPECT_TRUE(item.checked); |
| 310 EXPECT_FALSE(item.hidden); | 311 EXPECT_FALSE(item.hidden); |
| 311 } | 312 } |
| OLD | NEW |