| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void ForceSuggestMode() { | 231 void ForceSuggestMode() { |
| 232 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); | 232 menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true); |
| 233 // Force a non-empty and non-"en" locale so SUGGEST is available. | 233 // Force a non-empty and non-"en" locale so SUGGEST is available. |
| 234 menu()->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "fr"); | 234 menu()->GetPrefs()->SetString(prefs::kSpellCheckDictionary, "fr"); |
| 235 ASSERT_TRUE(SpellingServiceClient::IsAvailable( | 235 ASSERT_TRUE(SpellingServiceClient::IsAvailable( |
| 236 menu()->GetBrowserContext(), SpellingServiceClient::SUGGEST)); | 236 menu()->GetBrowserContext(), SpellingServiceClient::SUGGEST)); |
| 237 ASSERT_FALSE(SpellingServiceClient::IsAvailable( | 237 ASSERT_FALSE(SpellingServiceClient::IsAvailable( |
| 238 menu()->GetBrowserContext(), SpellingServiceClient::SPELLCHECK)); | 238 menu()->GetBrowserContext(), SpellingServiceClient::SPELLCHECK)); |
| 239 } | 239 } |
| 240 | 240 |
| 241 virtual ~SpellingMenuObserverTest(); | 241 ~SpellingMenuObserverTest() override; |
| 242 MockRenderViewContextMenu* menu() { return menu_.get(); } | 242 MockRenderViewContextMenu* menu() { return menu_.get(); } |
| 243 SpellingMenuObserver* observer() { return observer_.get(); } | 243 SpellingMenuObserver* observer() { return observer_.get(); } |
| 244 private: | 244 private: |
| 245 scoped_ptr<SpellingMenuObserver> observer_; | 245 scoped_ptr<SpellingMenuObserver> observer_; |
| 246 scoped_ptr<MockRenderViewContextMenu> menu_; | 246 scoped_ptr<MockRenderViewContextMenu> menu_; |
| 247 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserverTest); | 247 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserverTest); |
| 248 }; | 248 }; |
| 249 | 249 |
| 250 SpellingMenuObserverTest::SpellingMenuObserverTest() { | 250 SpellingMenuObserverTest::SpellingMenuObserverTest() { |
| 251 } | 251 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 ForceSuggestMode(); | 468 ForceSuggestMode(); |
| 469 InitMenu("asdfkj", NULL); | 469 InitMenu("asdfkj", NULL); |
| 470 | 470 |
| 471 // Should have at least 2 entries. Separator, suggestion. | 471 // Should have at least 2 entries. Separator, suggestion. |
| 472 EXPECT_LT(2U, menu()->GetMenuSize()); | 472 EXPECT_LT(2U, menu()->GetMenuSize()); |
| 473 menu()->GetMenuItem(0, &item); | 473 menu()->GetMenuItem(0, &item); |
| 474 EXPECT_EQ(-1, item.command_id); | 474 EXPECT_EQ(-1, item.command_id); |
| 475 menu()->GetMenuItem(1, &item); | 475 menu()->GetMenuItem(1, &item); |
| 476 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); | 476 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); |
| 477 } | 477 } |
| OLD | NEW |