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

Unified Diff: chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc

Issue 23726016: Show non-incognito browser in front of incognito browser when signing in from bookmark bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc
diff --git a/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc
index f15b0079df20240ed133b123cc89d3c6ee7d4efa..9b0c94940ea60bfa9a159bbc707323e6fb7a25d4 100644
--- a/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate_unittest.cc
@@ -10,10 +10,32 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/browser_with_test_window_test.h"
+#include "chrome/test/base/testing_profile.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/range/range.h"
-typedef BrowserWithTestWindowTest BookmarkBubbleSignInDelegateTest;
+class BookmarkBubbleSignInDelegateTest : public BrowserWithTestWindowTest {
+ public:
+ BookmarkBubbleSignInDelegateTest() {}
+
+ protected:
+ class Window : public TestBrowserWindow {
+ public:
+ Window() : show_count_(0) {}
+
+ // ui::BaseWindow:
+ virtual void Show() OVERRIDE {
tfarina 2013/08/31 01:32:05 can this be in private section? also // TestBrow
fdoray 2013/09/03 01:38:57 Done.
+ ++show_count_;
+ }
+
+ // Number of times that the Show() method has been called.
+ int show_count_;
tfarina 2013/08/31 01:32:05 please, make this private, add a public getter for
fdoray 2013/09/03 01:38:57 Done.
+ };
+
+ virtual BrowserWindow* CreateBrowserWindow() OVERRIDE {
+ return new Window();
+ }
+};
TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
int starting_tab_count = browser()->tab_strip_model()->count();
@@ -23,9 +45,54 @@ TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
delegate->OnSignInLinkClicked();
- // A new tab should have been opened.
+ // A new tab should have been opened and the browser should be visible.
int tab_count = browser()->tab_strip_model()->count();
EXPECT_EQ(starting_tab_count + 1, tab_count);
+ EXPECT_EQ(1,
+ static_cast<BookmarkBubbleSignInDelegateTest::Window*>(
+ browser()->window())->show_count_);
+}
+
+TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClickedIncognito) {
+ // Create an incognito browser.
+ TestingProfile::Builder incognito_profile_builder;
+ incognito_profile_builder.SetIncognito();
+ scoped_ptr<TestingProfile> incognito_profile =
+ incognito_profile_builder.Build();
+ incognito_profile->SetOriginalProfile(profile());
+ profile()->SetOffTheRecordProfile(incognito_profile.Pass());
+
+ scoped_ptr<BrowserWindow> incognito_window;
+ incognito_window.reset(CreateBrowserWindow());
+ Browser::CreateParams params(browser()->profile()->GetOffTheRecordProfile(),
+ browser()->host_desktop_type());
+ params.window = incognito_window.get();
+ scoped_ptr<Browser> incognito_browser;
+ incognito_browser.reset(new Browser(params));
+
+ int starting_tab_count_normal = browser()->tab_strip_model()->count();
+ int starting_tab_count_incognito =
+ incognito_browser.get()->tab_strip_model()->count();
+
+ scoped_ptr<BookmarkBubbleDelegate> delegate;
+ delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser.get()));
+
+ delegate->OnSignInLinkClicked();
+
+ // A new tab should have been opened in the normal browser, which should be
+ // visible.
+ int tab_count_normal = browser()->tab_strip_model()->count();
+ EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal);
+ EXPECT_EQ(1,
+ static_cast<BookmarkBubbleSignInDelegateTest::Window*>(
+ browser()->window())->show_count_);
+
+ // No effect is expected on the incognito browser.
+ int tab_count_incognito = incognito_browser->tab_strip_model()->count();
+ EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
+ EXPECT_EQ(0,
+ static_cast<BookmarkBubbleSignInDelegateTest::Window*>(
+ incognito_window.get())->show_count_);
}
// Verifies that the sign in page can be loaded in a different browser
@@ -53,9 +120,13 @@ TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
delegate->OnSignInLinkClicked();
- // A new tab should have been opened in the extra browser.
+ // A new tab should have been opened in the extra browser, which should be
+ // visible.
int tab_count = extra_browser->tab_strip_model()->count();
EXPECT_EQ(starting_tab_count + 1, tab_count);
+ EXPECT_EQ(1,
+ static_cast<BookmarkBubbleSignInDelegateTest::Window*>(
+ extra_window.get())->show_count_);
// Required to avoid a crash when the browser is deleted.
extra_browser->tab_strip_model()->CloseAllTabs();
« no previous file with comments | « chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698