Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views. h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "chrome/browser/ui/browser.h" | |
| 12 #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" | |
| 13 #include "chrome/browser/ui/tab_dialogs.h" | |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 15 #include "chrome/browser/ui/test/test_browser_dialog.h" | |
| 16 #include "components/bookmarks/browser/bookmark_model.h" | |
| 17 #include "ui/base/ui_base_switches.h" | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 // Test delegate passed to the confirmation dialog to report back the result. | |
|
msw
2017/02/09 18:09:54
nit: "to report back the result"? Seems like this
tapted
2017/02/09 23:16:10
ah, it allows the dialog to report. Or the delegat
| |
| 22 class TestSigninDialogDelegate : public ui::ProfileSigninConfirmationDelegate { | |
| 23 public: | |
| 24 TestSigninDialogDelegate() {} | |
| 25 virtual ~TestSigninDialogDelegate() {} | |
| 26 | |
| 27 void OnCancelSignin() override {} | |
| 28 void OnContinueSignin() override {} | |
| 29 void OnSigninWithNewProfile() override {} | |
| 30 | |
| 31 private: | |
| 32 DISALLOW_COPY_AND_ASSIGN(TestSigninDialogDelegate); | |
| 33 }; | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 class ProfileSigninConfirmationDialogTest : public DialogBrowserTest { | |
| 38 public: | |
| 39 ProfileSigninConfirmationDialogTest() {} | |
| 40 | |
| 41 // content::BrowserTestBase: | |
| 42 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 43 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); | |
| 44 } | |
| 45 | |
| 46 // DialogBrowserTest: | |
| 47 void ShowDialog(const std::string& name) override { | |
| 48 Profile* profile = browser()->profile(); | |
| 49 | |
| 50 // Add a bookmark to ensure CheckShouldPromptForNewProfile() returns true. | |
| 51 bookmarks::BookmarkModel* bookmarks = | |
| 52 BookmarkModelFactory::GetForBrowserContext(profile); | |
| 53 bookmarks->AddURL(bookmarks->bookmark_bar_node(), 0, | |
| 54 base::ASCIIToUTF16("title"), | |
| 55 GURL("http://www.example.com")); | |
| 56 | |
| 57 content::WebContents* web_contents = | |
| 58 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 59 TabDialogs::FromWebContents(web_contents) | |
| 60 ->ShowProfileSigninConfirmation( | |
| 61 browser(), profile, "username@example.com", | |
| 62 base::MakeUnique<TestSigninDialogDelegate>()); | |
| 63 } | |
| 64 | |
| 65 private: | |
| 66 DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialogTest); | |
| 67 }; | |
| 68 | |
| 69 // Test that calls ShowDialog("default"). Interactive when run via | |
| 70 // browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive | |
| 71 // --dialog=ProfileSigninConfirmationDialogTest.InvokeDialog_default | |
| 72 IN_PROC_BROWSER_TEST_F(ProfileSigninConfirmationDialogTest, | |
| 73 InvokeDialog_default) { | |
| 74 RunDialog(); | |
| 75 } | |
| OLD | NEW |