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

Side by Side Diff: chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_browsertest.cc

Issue 807503004: While trying to enable webview sign-in by default, I found a bunch of issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable tests for cros in gyp file Created 5 years, 11 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
(Empty)
1 // Copyright 2013 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/bookmarks/bookmark_bubble_sign_in_delegate.h"
6
7 #include "base/basictypes.h"
8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/test_extension_service.h"
12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/singleton_tabs.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/browser/notification_service.h"
22 #include "content/public/test/test_utils.h"
23 #include "ui/events/event_constants.h"
24 #include "ui/gfx/range/range.h"
25
26 class BookmarkBubbleSignInDelegateTest : public InProcessBrowserTest {
27 public:
28 BookmarkBubbleSignInDelegateTest() {}
29
30 Profile* profile() { return browser()->profile(); }
31
32 void ReplaceBlank(Browser* browser);
33
34 private:
35 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest);
36 };
37
38 void BookmarkBubbleSignInDelegateTest::ReplaceBlank(Browser* browser) {
39 // The default browser created for tests start with one tab open on
sky 2015/01/06 15:48:42 Move description above declaration.
Roger Tawa OOO till Jul 10th 2015/01/06 22:34:59 Done.
40 // about:blank. The sign-in page is a singleton that will
41 // replace this tab. This function replaces about:blank with another URL
42 // so that the sign in page goes into a new tab.
43 chrome::NavigateParams params(
44 chrome::GetSingletonTabNavigateParams(browser, GURL("chrome:version")));
45 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
46 chrome::ShowSingletonTabOverwritingNTP(browser, params);
sky 2015/01/06 15:48:42 Are you sure you don't need to wait for the naviga
Roger Tawa OOO till Jul 10th 2015/01/06 22:34:59 Does not seem like it is needed. Even though chro
47 }
48
49 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
50 ReplaceBlank(browser());
51 int starting_tab_count = browser()->tab_strip_model()->count();
52
53 scoped_ptr<BookmarkBubbleDelegate> delegate;
sky 2015/01/06 15:48:42 Is there a reason you need to wrap in scoped_ptr i
Roger Tawa OOO till Jul 10th 2015/01/06 22:34:59 The dtor of BookmarkBubbleSignInDelegate is privat
54 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
55
56 delegate->OnSignInLinkClicked();
57
58 // A new tab should have been opened and the browser should be visible.
59 content::RunAllPendingInMessageLoop();
sky 2015/01/06 15:48:42 Why do you need the RunAllPending in all of these?
Roger Tawa OOO till Jul 10th 2015/01/06 22:34:59 Not needed. All removed except line 118.
60 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
61 }
62
63 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
64 OnSignInLinkClickedReusesBlank) {
65 int starting_tab_count = browser()->tab_strip_model()->count();
66
67 scoped_ptr<BookmarkBubbleDelegate> delegate;
68 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
69
70 delegate->OnSignInLinkClicked();
71
72 // A new tab should have been opened and the browser should be visible.
73 content::RunAllPendingInMessageLoop();
74 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
75 }
76
77 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
78 OnSignInLinkClickedIncognito) {
79 ReplaceBlank(browser());
80 Browser* incognito_browser = CreateIncognitoBrowser();
81
82 int starting_tab_count_normal = browser()->tab_strip_model()->count();
83 int starting_tab_count_incognito =
84 incognito_browser->tab_strip_model()->count();
85
86 scoped_ptr<BookmarkBubbleDelegate> delegate;
87 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser));
88
89 delegate->OnSignInLinkClicked();
90
91 content::RunAllPendingInMessageLoop();
92
93 // A new tab should have been opened in the normal browser, which should be
94 // visible.
95 int tab_count_normal = browser()->tab_strip_model()->count();
96 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal);
97
98 // No effect is expected on the incognito browser.
99 int tab_count_incognito = incognito_browser->tab_strip_model()->count();
100 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
101 }
102
103 // Verifies that the sign in page can be loaded in a different browser
104 // if the provided browser is invalidated.
105 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
106 // Create an extra browser.
107 Browser* extra_browser = CreateBrowser(profile());
108 ReplaceBlank(extra_browser);
109
110 int starting_tab_count = extra_browser->tab_strip_model()->count();
111
112 scoped_ptr<BookmarkBubbleDelegate> delegate;
113 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
114
115 BrowserList::SetLastActive(extra_browser);
116
117 browser()->tab_strip_model()->CloseAllTabs();
118 content::RunAllPendingInMessageLoop();
119
120 delegate->OnSignInLinkClicked();
121
122 // A new tab should have been opened in the extra browser, which should be
123 // visible.
124 content::RunAllPendingInMessageLoop();
125 int tab_count = extra_browser->tab_strip_model()->count();
126 EXPECT_EQ(starting_tab_count + 1, tab_count);
127 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_browsertest.cc ('k') | chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698