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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 556173002: Ensure incognito TestingProfiles are incognito for their whole lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix CrOS Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/prefs/scoped_user_pref_update.h" 6 #include "base/prefs/scoped_user_pref_update.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 385 }
386 386
387 class OneClickSigninHelperIncognitoTest : public OneClickSigninHelperTest { 387 class OneClickSigninHelperIncognitoTest : public OneClickSigninHelperTest {
388 protected: 388 protected:
389 // content::RenderViewHostTestHarness. 389 // content::RenderViewHostTestHarness.
390 virtual content::BrowserContext* CreateBrowserContext() OVERRIDE; 390 virtual content::BrowserContext* CreateBrowserContext() OVERRIDE;
391 }; 391 };
392 392
393 content::BrowserContext* 393 content::BrowserContext*
394 OneClickSigninHelperIncognitoTest::CreateBrowserContext() { 394 OneClickSigninHelperIncognitoTest::CreateBrowserContext() {
395 // Builds an incognito profile to run this test. 395 // Simulate an incognito profile to run this test. RenderViewHostTestHarness
396 TestingProfile::Builder builder; 396 // takes ownership of the return value, so it can't be a "proper" incognito
397 builder.SetIncognito(); 397 // profile, since they are owned by their parent, non-incognito profile.
398 return builder.Build().release(); 398 scoped_ptr<TestingProfile> profile = TestingProfile::Builder().Build();
399 profile->ForceIncognito(true);
400 return profile.release();
399 } 401 }
tapted 2014/09/12 07:54:08 I didn't want to use `ForceIncognito` here, but it
400 402
401 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) { 403 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) {
402 std::string error_message; 404 std::string error_message;
403 EXPECT_FALSE(OneClickSigninHelper::CanOffer( 405 EXPECT_FALSE(OneClickSigninHelper::CanOffer(
404 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, 406 NULL, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY,
405 "user@gmail.com", &error_message)); 407 "user@gmail.com", &error_message));
406 EXPECT_EQ("", error_message); 408 EXPECT_EQ("", error_message);
407 EXPECT_FALSE(OneClickSigninHelper::CanOffer( 409 EXPECT_FALSE(OneClickSigninHelper::CanOffer(
408 NULL, OneClickSigninHelper::CAN_OFFER_FOR_ALL, 410 NULL, OneClickSigninHelper::CAN_OFFER_FOR_ALL,
409 "user@gmail.com", &error_message)); 411 "user@gmail.com", &error_message));
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 args.email = "foo@gmail.com"; 1016 args.email = "foo@gmail.com";
1015 args.profile = profile(); 1017 args.profile = profile();
1016 MockStarterWrapper* wrapper = new MockStarterWrapper( 1018 MockStarterWrapper* wrapper = new MockStarterWrapper(
1017 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); 1019 args, OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
1018 SetCookie("LSID=1234; domain=google.com; secure; httponly"); 1020 SetCookie("LSID=1234; domain=google.com; secure; httponly");
1019 1021
1020 EXPECT_CALL(*wrapper, DisplayErrorBubble(_)); 1022 EXPECT_CALL(*wrapper, DisplayErrorBubble(_));
1021 wrapper->Start(); 1023 wrapper->Start();
1022 base::RunLoop().RunUntilIdle(); 1024 base::RunLoop().RunUntilIdle();
1023 } 1025 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698