Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / ui / bookmarks / bookmark_bubble_sign_in_delegate_unittest.cc
blobf15b0079df20240ed133b123cc89d3c6ee7d4efa
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.
5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_list.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "ui/base/events/event_constants.h"
14 #include "ui/base/range/range.h"
16 typedef BrowserWithTestWindowTest BookmarkBubbleSignInDelegateTest;
18 TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
19 int starting_tab_count = browser()->tab_strip_model()->count();
21 scoped_ptr<BookmarkBubbleDelegate> delegate;
22 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
24 delegate->OnSignInLinkClicked();
26 // A new tab should have been opened.
27 int tab_count = browser()->tab_strip_model()->count();
28 EXPECT_EQ(starting_tab_count + 1, tab_count);
31 // Verifies that the sign in page can be loaded in a different browser
32 // if the provided browser is invalidated.
33 TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
34 // Create an extra browser.
35 scoped_ptr<BrowserWindow> extra_window;
36 extra_window.reset(CreateBrowserWindow());
38 Browser::CreateParams params(browser()->profile(),
39 browser()->host_desktop_type());
40 params.window = extra_window.get();
41 scoped_ptr<Browser> extra_browser;
42 extra_browser.reset(new Browser(params));
44 int starting_tab_count = extra_browser->tab_strip_model()->count();
46 scoped_ptr<BookmarkBubbleDelegate> delegate;
47 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
49 BrowserList::SetLastActive(extra_browser.get());
51 browser()->tab_strip_model()->CloseAllTabs();
52 set_browser(NULL);
54 delegate->OnSignInLinkClicked();
56 // A new tab should have been opened in the extra browser.
57 int tab_count = extra_browser->tab_strip_model()->count();
58 EXPECT_EQ(starting_tab_count + 1, tab_count);
60 // Required to avoid a crash when the browser is deleted.
61 extra_browser->tab_strip_model()->CloseAllTabs();