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/ui/sync/profile_signin_confirmation_helper.h" | |
| 11 #include "chrome/browser/ui/tab_dialogs.h" | |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 13 #include "chrome/browser/ui/test/test_browser_dialog.h" | |
| 14 #include "components/bookmarks/browser/bookmark_model.h" | |
| 15 #include "ui/base/ui_base_switches.h" | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 class TestSigninDialogDelegate : public ui::ProfileSigninConfirmationDelegate { | |
|
msw
2017/01/13 23:23:51
optional nit: comment
tapted
2017/01/13 23:48:45
Done.
| |
| 20 public: | |
| 21 TestSigninDialogDelegate() {} | |
| 22 virtual ~TestSigninDialogDelegate() {} | |
| 23 | |
| 24 void OnCancelSignin() override {} | |
| 25 void OnContinueSignin() override {} | |
| 26 void OnSigninWithNewProfile() override {} | |
| 27 | |
| 28 private: | |
| 29 DISALLOW_COPY_AND_ASSIGN(TestSigninDialogDelegate); | |
| 30 }; | |
| 31 | |
| 32 } // namespace | |
| 33 | |
| 34 class ProfileSigninConfirmationDialogTest : public DialogBrowserTest { | |
| 35 public: | |
| 36 ProfileSigninConfirmationDialogTest() {} | |
| 37 | |
| 38 // content::BrowserTestBase: | |
| 39 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 40 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi); | |
| 41 } | |
| 42 | |
| 43 // TestDialogInterface: | |
|
msw
2017/01/13 23:23:51
nit: use the appropriate base class name.
(optiona
tapted
2017/01/13 23:48:45
Done & Done. Although I guess I should start a chr
msw
2017/01/13 23:53:52
I'm not picky, just don't use the non-existent 'Te
tapted
2017/01/14 00:06:23
Ohhhhh. Doh - you're right. I forgot I renamed it
| |
| 44 void ShowDialog(const std::string& name) override { | |
| 45 Profile* profile = browser()->profile(); | |
| 46 | |
| 47 // Add a bookmark to ensure CheckShouldPromptForNewProfile() returns true. | |
| 48 bookmarks::BookmarkModel* bookmarks = | |
| 49 BookmarkModelFactory::GetForBrowserContext(profile); | |
| 50 bookmarks->AddURL(bookmarks->bookmark_bar_node(), 0, | |
| 51 base::ASCIIToUTF16("title"), | |
| 52 GURL("http://www.example.com")); | |
| 53 | |
| 54 content::WebContents* web_contents = | |
| 55 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 56 TabDialogs::FromWebContents(web_contents) | |
| 57 ->ShowProfileSigninConfirmation( | |
| 58 browser(), profile, "username@example.com", | |
| 59 base::MakeUnique<TestSigninDialogDelegate>()); | |
| 60 } | |
| 61 | |
| 62 private: | |
| 63 DISALLOW_COPY_AND_ASSIGN(ProfileSigninConfirmationDialogTest); | |
| 64 }; | |
| 65 | |
| 66 // Test that calls ShowDialog("default"). Interactive when run via | |
| 67 // browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive | |
| 68 // --dialog=ProfileSigninConfirmationDialogTest.InvokeDialog_default | |
| 69 IN_PROC_BROWSER_TEST_F(ProfileSigninConfirmationDialogTest, | |
| 70 InvokeDialog_default) { | |
| 71 RunDialog(); | |
| 72 } | |
| OLD | NEW |