Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7079)

Unified Diff: chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc
diff --git a/chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc b/chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc
index ae5c0a027ab3ceb347e545e7cf8932bbee86a838..ad3e7fab682eaaaf693a1e2b47afb762149fd8cd 100644
--- a/chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc
+++ b/chrome/browser/tab_contents/spelling_menu_observer_browsertest.cc
@@ -44,7 +44,7 @@ class MockRenderViewContextMenu : public RenderViewContextMenuProxy {
string16 title;
};
- MockRenderViewContextMenu();
+ explicit MockRenderViewContextMenu(bool incognito);
virtual ~MockRenderViewContextMenu();
// RenderViewContextMenuProxy implementation.
@@ -89,9 +89,12 @@ class MockRenderViewContextMenu : public RenderViewContextMenuProxy {
DISALLOW_COPY_AND_ASSIGN(MockRenderViewContextMenu);
};
-MockRenderViewContextMenu::MockRenderViewContextMenu()
- : observer_(NULL),
- profile_(new TestingProfile) {
+MockRenderViewContextMenu::MockRenderViewContextMenu(bool incognito)
+ : observer_(NULL) {
+ TestingProfile::Builder builder;
+ if (incognito)
+ builder.SetIncognito();
+ profile_ = builder.Build();
}
MockRenderViewContextMenu::~MockRenderViewContextMenu() {
@@ -202,7 +205,7 @@ class SpellingMenuObserverTest : public InProcessBrowserTest {
SpellingMenuObserverTest();
virtual void SetUpOnMainThread() OVERRIDE {
- Reset();
+ Reset(false);
}
virtual void CleanUpOnMainThread() OVERRIDE {
@@ -210,9 +213,9 @@ class SpellingMenuObserverTest : public InProcessBrowserTest {
menu_.reset();
}
- void Reset() {
+ void Reset(bool incognito) {
observer_.reset();
- menu_.reset(new MockRenderViewContextMenu);
+ menu_.reset(new MockRenderViewContextMenu(incognito));
observer_.reset(new SpellingMenuObserver(menu_.get()));
menu_->SetObserver(observer_.get());
}
@@ -395,7 +398,8 @@ IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest,
// is functional.
IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest,
NoSpellingServiceWhenOffTheRecord) {
- menu()->GetProfile()->AsTestingProfile()->set_incognito(true);
+ // Create a menu in an incognito profile.
+ Reset(true);
// This means spellchecking is allowed. Default is that the service is
// contacted but this test makes sure that if profile is incognito, that
@@ -433,9 +437,6 @@ IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest,
EXPECT_EQ(IDC_CONTENT_CONTEXT_SPELLING_TOGGLE, item.command_id);
EXPECT_FALSE(item.enabled);
EXPECT_FALSE(item.hidden);
-
- // Set incognito back to false to allow appropriate test cleanup.
- menu()->GetProfile()->AsTestingProfile()->set_incognito(false);
}
// Test that the menu is preceeded by a separator if there are any suggestions,
@@ -452,7 +453,7 @@ IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SuggestionsForceTopSeparator) {
EXPECT_NE(-1, item.command_id);
// Case #2. Misspelled word, suggestions, no spellcheck service.
- Reset();
+ Reset(false);
menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, false);
InitMenu("asdfkj", "asdf");
@@ -463,7 +464,7 @@ IN_PROC_BROWSER_TEST_F(SpellingMenuObserverTest, SuggestionsForceTopSeparator) {
EXPECT_EQ(-1, item.command_id);
// Case #3. Misspelled word, suggestion service is on.
- Reset();
+ Reset(false);
menu()->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, true);
CommandLine* command_line = CommandLine::ForCurrentProcess();
command_line->AppendSwitch(switches::kUseSpellingSuggestions);
« no previous file with comments | « chrome/browser/sync/profile_sync_service_unittest.cc ('k') | chrome/browser/translate/translate_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698