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

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

Issue 120343004: Reland r242290, r241609, r242134. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h" 5 #include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/extensions/test_extension_service.h"
11 #include "chrome/browser/extensions/test_extension_system.h"
9 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h" 12 #include "chrome/browser/ui/bookmarks/bookmark_bubble_delegate.h"
10 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/browser_with_test_window_test.h" 16 #include "chrome/test/base/browser_with_test_window_test.h"
14 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
15 #include "ui/events/event_constants.h" 18 #include "ui/events/event_constants.h"
16 #include "ui/gfx/range/range.h" 19 #include "ui/gfx/range/range.h"
17 20
18 class BookmarkBubbleSignInDelegateTest : public BrowserWithTestWindowTest { 21 class BookmarkBubbleSignInDelegateTest : public BrowserWithTestWindowTest {
19 public: 22 public:
20 BookmarkBubbleSignInDelegateTest() {} 23 BookmarkBubbleSignInDelegateTest() {}
21 24
25 virtual void SetUp() OVERRIDE;
26
22 protected: 27 protected:
23 class Window : public TestBrowserWindow { 28 class Window : public TestBrowserWindow {
24 public: 29 public:
25 Window() : show_count_(0) {} 30 Window() : show_count_(0) {}
26 31
27 int show_count() { return show_count_; } 32 int show_count() { return show_count_; }
28 33
29 private: 34 private:
30 // TestBrowserWindow: 35 // TestBrowserWindow:
31 virtual void Show() OVERRIDE { 36 virtual void Show() OVERRIDE {
32 ++show_count_; 37 ++show_count_;
33 } 38 }
34 39
35 // Number of times that the Show() method has been called. 40 // Number of times that the Show() method has been called.
36 int show_count_; 41 int show_count_;
37 42
38 DISALLOW_COPY_AND_ASSIGN(Window); 43 DISALLOW_COPY_AND_ASSIGN(Window);
39 }; 44 };
40 45
41 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE { 46 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE {
42 return new Window(); 47 return new Window();
43 } 48 }
44 49
45 private: 50 private:
46 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest); 51 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleSignInDelegateTest);
47 }; 52 };
48 53
54 void BookmarkBubbleSignInDelegateTest::SetUp() {
55 BrowserWithTestWindowTest::SetUp();
56 // Adds TestExtensionSystem, since signin uses the gaia auth extension.
57 static_cast<extensions::TestExtensionSystem*>(
58 extensions::ExtensionSystem::Get(profile()))->CreateExtensionService(
59 CommandLine::ForCurrentProcess(), base::FilePath(), false);
60 }
61
49 TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { 62 TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
50 int starting_tab_count = browser()->tab_strip_model()->count(); 63 int starting_tab_count = browser()->tab_strip_model()->count();
51 64
52 scoped_ptr<BookmarkBubbleDelegate> delegate; 65 scoped_ptr<BookmarkBubbleDelegate> delegate;
53 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 66 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
54 67
55 delegate->OnSignInLinkClicked(); 68 delegate->OnSignInLinkClicked();
56 69
57 // A new tab should have been opened and the browser should be visible. 70 // A new tab should have been opened and the browser should be visible.
58 int tab_count = browser()->tab_strip_model()->count(); 71 int tab_count = browser()->tab_strip_model()->count();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // visible. 146 // visible.
134 int tab_count = extra_browser->tab_strip_model()->count(); 147 int tab_count = extra_browser->tab_strip_model()->count();
135 EXPECT_EQ(starting_tab_count + 1, tab_count); 148 EXPECT_EQ(starting_tab_count + 1, tab_count);
136 EXPECT_LE(1, 149 EXPECT_LE(1,
137 static_cast<BookmarkBubbleSignInDelegateTest::Window*>( 150 static_cast<BookmarkBubbleSignInDelegateTest::Window*>(
138 extra_window.get())->show_count()); 151 extra_window.get())->show_count());
139 152
140 // Required to avoid a crash when the browser is deleted. 153 // Required to avoid a crash when the browser is deleted.
141 extra_browser->tab_strip_model()->CloseAllTabs(); 154 extra_browser->tab_strip_model()->CloseAllTabs();
142 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698