| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 void Reset(bool incognito) { | 218 void Reset(bool incognito) { |
| 219 observer_.reset(); | 219 observer_.reset(); |
| 220 menu_.reset(new MockRenderViewContextMenu(incognito)); | 220 menu_.reset(new MockRenderViewContextMenu(incognito)); |
| 221 observer_.reset(new SpellingMenuObserver(menu_.get())); | 221 observer_.reset(new SpellingMenuObserver(menu_.get())); |
| 222 menu_->SetObserver(observer_.get()); | 222 menu_->SetObserver(observer_.get()); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void InitMenu(const char* word, const char* suggestion) { | 225 void InitMenu(const char* word, const char* suggestion) { |
| 226 content::ContextMenuParams params; | 226 content::ContextMenuParams params; |
| 227 params.is_editable = true; | 227 params.is_editable = true; |
| 228 params.misspelled_word = ASCIIToUTF16(word); | 228 params.misspelled_word = base::ASCIIToUTF16(word); |
| 229 params.dictionary_suggestions.clear(); | 229 params.dictionary_suggestions.clear(); |
| 230 if (suggestion) | 230 if (suggestion) |
| 231 params.dictionary_suggestions.push_back(ASCIIToUTF16(suggestion)); | 231 params.dictionary_suggestions.push_back(base::ASCIIToUTF16(suggestion)); |
| 232 observer_->InitMenu(params); | 232 observer_->InitMenu(params); |
| 233 } | 233 } |
| 234 | 234 |
| 235 virtual ~SpellingMenuObserverTest(); | 235 virtual ~SpellingMenuObserverTest(); |
| 236 MockRenderViewContextMenu* menu() { return menu_.get(); } | 236 MockRenderViewContextMenu* menu() { return menu_.get(); } |
| 237 SpellingMenuObserver* observer() { return observer_.get(); } | 237 SpellingMenuObserver* observer() { return observer_.get(); } |
| 238 private: | 238 private: |
| 239 scoped_ptr<SpellingMenuObserver> observer_; | 239 scoped_ptr<SpellingMenuObserver> observer_; |
| 240 scoped_ptr<MockRenderViewContextMenu> menu_; | 240 scoped_ptr<MockRenderViewContextMenu> menu_; |
| 241 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserverTest); | 241 DISALLOW_COPY_AND_ASSIGN(SpellingMenuObserverTest); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 command_line->AppendSwitch(switches::kUseSpellingSuggestions); | 472 command_line->AppendSwitch(switches::kUseSpellingSuggestions); |
| 473 InitMenu("asdfkj", NULL); | 473 InitMenu("asdfkj", NULL); |
| 474 | 474 |
| 475 // Should have at least 2 entries. Separator, suggestion. | 475 // Should have at least 2 entries. Separator, suggestion. |
| 476 EXPECT_LT(2U, menu()->GetMenuSize()); | 476 EXPECT_LT(2U, menu()->GetMenuSize()); |
| 477 menu()->GetMenuItem(0, &item); | 477 menu()->GetMenuItem(0, &item); |
| 478 EXPECT_EQ(-1, item.command_id); | 478 EXPECT_EQ(-1, item.command_id); |
| 479 menu()->GetMenuItem(1, &item); | 479 menu()->GetMenuItem(1, &item); |
| 480 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); | 480 EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, item.command_id); |
| 481 } | 481 } |
| OLD | NEW |