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

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

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
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 <memory>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
11 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/test_extension_service.h" 13 #include "chrome/browser/extensions/test_extension_service.h"
13 #include "chrome/browser/extensions/test_extension_system.h" 14 #include "chrome/browser/extensions/test_extension_system.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_navigator_params.h" 17 #include "chrome/browser/ui/browser_navigator_params.h"
17 #include "chrome/browser/ui/singleton_tabs.h" 18 #include "chrome/browser/ui/singleton_tabs.h"
18 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" 19 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 chrome::NavigateParams params( 53 chrome::NavigateParams params(
53 chrome::GetSingletonTabNavigateParams(browser, GURL("chrome:version"))); 54 chrome::GetSingletonTabNavigateParams(browser, GURL("chrome:version")));
54 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE; 55 params.path_behavior = chrome::NavigateParams::IGNORE_AND_NAVIGATE;
55 chrome::ShowSingletonTabOverwritingNTP(browser, params); 56 chrome::ShowSingletonTabOverwritingNTP(browser, params);
56 } 57 }
57 58
58 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) { 59 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, OnSignInLinkClicked) {
59 ReplaceBlank(browser()); 60 ReplaceBlank(browser());
60 int starting_tab_count = browser()->tab_strip_model()->count(); 61 int starting_tab_count = browser()->tab_strip_model()->count();
61 62
62 scoped_ptr<BubbleSyncPromoDelegate> delegate; 63 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
63 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 64 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
64 65
65 delegate->OnSignInLinkClicked(); 66 delegate->OnSignInLinkClicked();
66 67
67 if (kHasProfileChooser) { 68 if (kHasProfileChooser) {
68 EXPECT_TRUE(ProfileChooserView::IsShowing()); 69 EXPECT_TRUE(ProfileChooserView::IsShowing());
69 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 70 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
70 } else { 71 } else {
71 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count()); 72 EXPECT_EQ(starting_tab_count + 1, browser()->tab_strip_model()->count());
72 } 73 }
73 } 74 }
74 75
75 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 76 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
76 OnSignInLinkClickedReusesBlank) { 77 OnSignInLinkClickedReusesBlank) {
77 int starting_tab_count = browser()->tab_strip_model()->count(); 78 int starting_tab_count = browser()->tab_strip_model()->count();
78 79
79 scoped_ptr<BubbleSyncPromoDelegate> delegate; 80 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
80 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 81 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
81 82
82 delegate->OnSignInLinkClicked(); 83 delegate->OnSignInLinkClicked();
83 84
84 if (kHasProfileChooser) { 85 if (kHasProfileChooser) {
85 EXPECT_TRUE(ProfileChooserView::IsShowing()); 86 EXPECT_TRUE(ProfileChooserView::IsShowing());
86 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 87 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
87 } else { 88 } else {
88 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count()); 89 EXPECT_EQ(starting_tab_count, browser()->tab_strip_model()->count());
89 } 90 }
90 } 91 }
91 92
92 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, 93 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest,
93 OnSignInLinkClickedIncognito) { 94 OnSignInLinkClickedIncognito) {
94 ReplaceBlank(browser()); 95 ReplaceBlank(browser());
95 Browser* incognito_browser = CreateIncognitoBrowser(); 96 Browser* incognito_browser = CreateIncognitoBrowser();
96 97
97 int starting_tab_count_normal = browser()->tab_strip_model()->count(); 98 int starting_tab_count_normal = browser()->tab_strip_model()->count();
98 int starting_tab_count_incognito = 99 int starting_tab_count_incognito =
99 incognito_browser->tab_strip_model()->count(); 100 incognito_browser->tab_strip_model()->count();
100 101
101 scoped_ptr<BubbleSyncPromoDelegate> delegate; 102 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
102 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser)); 103 delegate.reset(new BookmarkBubbleSignInDelegate(incognito_browser));
103 104
104 delegate->OnSignInLinkClicked(); 105 delegate->OnSignInLinkClicked();
105 106
106 if (kHasProfileChooser) { 107 if (kHasProfileChooser) {
107 // ProfileChooser doesn't show in an incognito window. 108 // ProfileChooser doesn't show in an incognito window.
108 EXPECT_FALSE(ProfileChooserView::IsShowing()); 109 EXPECT_FALSE(ProfileChooserView::IsShowing());
109 } else { 110 } else {
110 // A new tab should have been opened in the normal browser, which should be 111 // A new tab should have been opened in the normal browser, which should be
111 // visible. 112 // visible.
112 int tab_count_normal = browser()->tab_strip_model()->count(); 113 int tab_count_normal = browser()->tab_strip_model()->count();
113 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal); 114 EXPECT_EQ(starting_tab_count_normal + 1, tab_count_normal);
114 } 115 }
115 // No effect is expected on the incognito browser. 116 // No effect is expected on the incognito browser.
116 int tab_count_incognito = incognito_browser->tab_strip_model()->count(); 117 int tab_count_incognito = incognito_browser->tab_strip_model()->count();
117 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito); 118 EXPECT_EQ(starting_tab_count_incognito, tab_count_incognito);
118 } 119 }
119 120
120 // Verifies that the sign in page can be loaded in a different browser 121 // Verifies that the sign in page can be loaded in a different browser
121 // if the provided browser is invalidated. 122 // if the provided browser is invalidated.
122 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) { 123 IN_PROC_BROWSER_TEST_F(BookmarkBubbleSignInDelegateTest, BrowserRemoved) {
123 // Create an extra browser. 124 // Create an extra browser.
124 Browser* extra_browser = CreateBrowser(profile()); 125 Browser* extra_browser = CreateBrowser(profile());
125 ReplaceBlank(extra_browser); 126 ReplaceBlank(extra_browser);
126 127
127 int starting_tab_count = extra_browser->tab_strip_model()->count(); 128 int starting_tab_count = extra_browser->tab_strip_model()->count();
128 129
129 scoped_ptr<BubbleSyncPromoDelegate> delegate; 130 std::unique_ptr<BubbleSyncPromoDelegate> delegate;
130 delegate.reset(new BookmarkBubbleSignInDelegate(browser())); 131 delegate.reset(new BookmarkBubbleSignInDelegate(browser()));
131 132
132 BrowserList::SetLastActive(extra_browser); 133 BrowserList::SetLastActive(extra_browser);
133 134
134 // Close all tabs in the original browser. Run all pending messages 135 // Close all tabs in the original browser. Run all pending messages
135 // to make sure the browser window closes before continuing. 136 // to make sure the browser window closes before continuing.
136 browser()->tab_strip_model()->CloseAllTabs(); 137 browser()->tab_strip_model()->CloseAllTabs();
137 content::RunAllPendingInMessageLoop(); 138 content::RunAllPendingInMessageLoop();
138 139
139 delegate->OnSignInLinkClicked(); 140 delegate->OnSignInLinkClicked();
140 141
141 if (kHasProfileChooser) { 142 if (kHasProfileChooser) {
142 EXPECT_TRUE(ProfileChooserView::IsShowing()); 143 EXPECT_TRUE(ProfileChooserView::IsShowing());
143 } else { 144 } else {
144 // A new tab should have been opened in the extra browser, which should be 145 // A new tab should have been opened in the extra browser, which should be
145 // visible. 146 // visible.
146 int tab_count = extra_browser->tab_strip_model()->count(); 147 int tab_count = extra_browser->tab_strip_model()->count();
147 EXPECT_EQ(starting_tab_count + 1, tab_count); 148 EXPECT_EQ(starting_tab_count + 1, tab_count);
148 } 149 }
149 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698