Chromium Code Reviews| 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 "base/message_loop.h" | |
| 5 #include "chrome/browser/content_settings/cookie_settings.h" | 6 #include "chrome/browser/content_settings/cookie_settings.h" |
| 6 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/signin/signin_manager_fake.h" | 11 #include "chrome/browser/signin/signin_manager_fake.h" |
| 11 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 12 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 scoped_ptr<content::WebContents> web_contents_; | 59 scoped_ptr<content::WebContents> web_contents_; |
| 59 scoped_ptr<TestingProfile> profile_; | 60 scoped_ptr<TestingProfile> profile_; |
| 60 SigninManager* signin_manager_; | 61 SigninManager* signin_manager_; |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelperTest); | 63 DISALLOW_COPY_AND_ASSIGN(OneClickSigninHelperTest); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 void OneClickSigninHelperTest::TearDown() { | 66 void OneClickSigninHelperTest::TearDown() { |
| 66 // Destroy things in proper order. | 67 // Destroy things in proper order. |
| 67 web_contents_.reset(); | 68 web_contents_.reset(); |
| 69 | |
| 70 // Flush messages related web contents destruction before destroying the | |
|
Derek Bruening
2012/06/01 15:04:24
nit: grammar
| |
| 71 // browser context. | |
| 72 MessageLoop::current()->RunAllPending(); | |
| 68 profile_.reset(); | 73 profile_.reset(); |
| 74 | |
| 69 ui_thread_.reset(); | 75 ui_thread_.reset(); |
| 70 } | 76 } |
| 71 | 77 |
| 72 void OneClickSigninHelperTest::MarkCurrentThreadAsUIThread() { | 78 void OneClickSigninHelperTest::MarkCurrentThreadAsUIThread() { |
| 73 ui_thread_.reset(new content::TestBrowserThread( | 79 ui_thread_.reset(new content::TestBrowserThread( |
| 74 content::BrowserThread::UI, &message_loop_)); | 80 content::BrowserThread::UI, &message_loop_)); |
| 75 } | 81 } |
| 76 | 82 |
| 77 content::WebContents* OneClickSigninHelperTest::CreateMockWebContents( | 83 content::WebContents* OneClickSigninHelperTest::CreateMockWebContents( |
| 78 bool use_incognito) { | 84 bool use_incognito) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 TEST_F(OneClickSigninHelperTest, CanOfferIncognito) { | 145 TEST_F(OneClickSigninHelperTest, CanOfferIncognito) { |
| 140 MarkCurrentThreadAsUIThread(); | 146 MarkCurrentThreadAsUIThread(); |
| 141 content::WebContents* web_contents = CreateMockWebContents(true); | 147 content::WebContents* web_contents = CreateMockWebContents(true); |
| 142 | 148 |
| 143 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, true)); | 149 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, true)); |
| 144 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, false)); | 150 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, false)); |
| 145 } | 151 } |
| 146 | 152 |
| 147 TEST_F(OneClickSigninHelperTest, CanOfferNoSigninCookies) { | 153 TEST_F(OneClickSigninHelperTest, CanOfferNoSigninCookies) { |
| 148 MarkCurrentThreadAsUIThread(); | 154 MarkCurrentThreadAsUIThread(); |
| 149 content::WebContents* web_contents = CreateMockWebContents(true); | 155 content::WebContents* web_contents = CreateMockWebContents(false); |
| 150 AllowSigninCookies(false); | 156 AllowSigninCookies(false); |
| 151 | 157 |
| 152 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, true)); | 158 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, true)); |
| 153 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, false)); | 159 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, false)); |
| 154 } | 160 } |
| OLD | NEW |