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

Side by Side Diff: chrome/browser/ui/webui/signin/sync_confirmation_handler_unittest.cc

Issue 2784823002: Reland "Use the same browser instance in the sync confirmation dialog. (Closed)
Patch Set: Rebase and fix conflicts Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/signin/sync_confirmation_handler.h" 5 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h"
6 6
7 #include "base/test/user_action_tester.h" 7 #include "base/test/user_action_tester.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 9 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
10 #include "chrome/browser/signin/account_fetcher_service_factory.h" 10 #include "chrome/browser/signin/account_fetcher_service_factory.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/public/test/test_web_ui.h" 27 #include "content/public/test/test_web_ui.h"
28 28
29 const int kExpectedProfileImageSize = 128; 29 const int kExpectedProfileImageSize = 128;
30 30
31 // The dialog needs to be initialized with a height but the actual value doesn't 31 // The dialog needs to be initialized with a height but the actual value doesn't
32 // really matter in unit tests. 32 // really matter in unit tests.
33 const double kDefaultDialogHeight = 350.0; 33 const double kDefaultDialogHeight = 350.0;
34 34
35 class TestingSyncConfirmationHandler : public SyncConfirmationHandler { 35 class TestingSyncConfirmationHandler : public SyncConfirmationHandler {
36 public: 36 public:
37 explicit TestingSyncConfirmationHandler(content::WebUI* web_ui) { 37 explicit TestingSyncConfirmationHandler(Browser* browser,
38 content::WebUI* web_ui)
39 : SyncConfirmationHandler(browser) {
38 set_web_ui(web_ui); 40 set_web_ui(web_ui);
39 } 41 }
40 42
41 using SyncConfirmationHandler::HandleConfirm; 43 using SyncConfirmationHandler::HandleConfirm;
42 using SyncConfirmationHandler::HandleUndo; 44 using SyncConfirmationHandler::HandleUndo;
43 using SyncConfirmationHandler::HandleInitializedWithSize; 45 using SyncConfirmationHandler::HandleInitializedWithSize;
44 using SyncConfirmationHandler::HandleGoToSettings; 46 using SyncConfirmationHandler::HandleGoToSettings;
45 using SyncConfirmationHandler::SetUserImageURL; 47 using SyncConfirmationHandler::SetUserImageURL;
46 }; 48 };
47 49
48 class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest { 50 class SyncConfirmationHandlerTest : public BrowserWithTestWindowTest {
49 public: 51 public:
50 SyncConfirmationHandlerTest() : did_user_explicitly_interact(false), 52 SyncConfirmationHandlerTest() : did_user_explicitly_interact(false),
51 web_ui_(new content::TestWebUI) {} 53 web_ui_(new content::TestWebUI) {}
52 void SetUp() override { 54 void SetUp() override {
53 BrowserWithTestWindowTest::SetUp(); 55 BrowserWithTestWindowTest::SetUp();
54 chrome::NewTab(browser()); 56 chrome::NewTab(browser());
55 web_ui()->set_web_contents( 57 web_ui()->set_web_contents(
56 browser()->tab_strip_model()->GetActiveWebContents()); 58 browser()->tab_strip_model()->GetActiveWebContents());
57 59
58 auto handler = base::MakeUnique<TestingSyncConfirmationHandler>(web_ui()); 60 auto handler =
61 base::MakeUnique<TestingSyncConfirmationHandler>(browser(), web_ui());
59 handler_ = handler.get(); 62 handler_ = handler.get();
60 sync_confirmation_ui_.reset( 63 sync_confirmation_ui_.reset(new SyncConfirmationUI(web_ui()));
61 new SyncConfirmationUI(web_ui(), std::move(handler))); 64 web_ui()->AddMessageHandler(std::move(handler));
62 65
63 // This dialog assumes the signin flow was completed, which kicks off the 66 // This dialog assumes the signin flow was completed, which kicks off the
64 // SigninManager. 67 // SigninManager.
65 new OneClickSigninSyncStarter( 68 new OneClickSigninSyncStarter(
66 profile(), browser(), "gaia", "foo@example.com", "password", 69 profile(), browser(), "gaia", "foo@example.com", "password",
67 "refresh_token", OneClickSigninSyncStarter::CURRENT_PROFILE, 70 "refresh_token", OneClickSigninSyncStarter::CURRENT_PROFILE,
68 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, nullptr, 71 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS, nullptr,
69 OneClickSigninSyncStarter::NO_CONFIRMATION, GURL(), GURL(), 72 OneClickSigninSyncStarter::NO_CONFIRMATION, GURL(), GURL(),
70 OneClickSigninSyncStarter::Callback()); 73 OneClickSigninSyncStarter::Callback());
71 } 74 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 EXPECT_FALSE(sync()->IsFirstSetupInProgress()); 282 EXPECT_FALSE(sync()->IsFirstSetupInProgress());
280 EXPECT_TRUE(sync()->IsFirstSetupComplete()); 283 EXPECT_TRUE(sync()->IsFirstSetupComplete());
281 EXPECT_TRUE( 284 EXPECT_TRUE(
282 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated()); 285 SigninManagerFactory::GetForProfile(profile())->IsAuthenticated());
283 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin")); 286 EXPECT_EQ(0, user_action_tester()->GetActionCount("Signin_Undo_Signin"));
284 EXPECT_EQ(1, user_action_tester()->GetActionCount( 287 EXPECT_EQ(1, user_action_tester()->GetActionCount(
285 "Signin_Signin_WithDefaultSyncSettings")); 288 "Signin_Signin_WithDefaultSyncSettings"));
286 EXPECT_EQ(0, user_action_tester()->GetActionCount( 289 EXPECT_EQ(0, user_action_tester()->GetActionCount(
287 "Signin_Signin_WithAdvancedSyncSettings")); 290 "Signin_Signin_WithAdvancedSyncSettings"));
288 } 291 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/sync_confirmation_handler.cc ('k') | chrome/browser/ui/webui/signin/sync_confirmation_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698