OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/extension_message_bubble_browsertest.h" | 5 #include "chrome/browser/ui/extensions/extension_message_bubble_browsertest.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 base::RunLoop().RunUntilIdle(); | 209 base::RunLoop().RunUntilIdle(); |
210 | 210 |
211 // The bubble was already shown, so it shouldn't be shown again. | 211 // The bubble was already shown, so it shouldn't be shown again. |
212 Browser* third_browser = new Browser(Browser::CreateParams(profile(), true)); | 212 Browser* third_browser = new Browser(Browser::CreateParams(profile(), true)); |
213 ASSERT_TRUE(third_browser); | 213 ASSERT_TRUE(third_browser); |
214 third_browser->window()->Show(); | 214 third_browser->window()->Show(); |
215 base::RunLoop().RunUntilIdle(); | 215 base::RunLoop().RunUntilIdle(); |
216 CheckBubbleIsNotPresent(third_browser, false, false); | 216 CheckBubbleIsNotPresent(third_browser, false, false); |
217 } | 217 } |
218 | 218 |
219 void ExtensionMessageBubbleBrowserTest::TestControlledNewTabPageBubbleShown() { | 219 void ExtensionMessageBubbleBrowserTest::TestControlledNewTabPageBubbleShown( |
| 220 bool click_learn_more) { |
220 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") | 221 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") |
221 .AppendASCII("override") | 222 .AppendASCII("override") |
222 .AppendASCII("newtab"))); | 223 .AppendASCII("newtab"))); |
223 CheckBubbleIsNotPresent(browser(), false, false); | 224 CheckBubbleIsNotPresent(browser(), false, false); |
| 225 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
224 chrome::NewTab(browser()); | 226 chrome::NewTab(browser()); |
| 227 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
225 base::RunLoop().RunUntilIdle(); | 228 base::RunLoop().RunUntilIdle(); |
226 CheckBubble(browser(), ANCHOR_BROWSER_ACTION, false); | 229 CheckBubble(browser(), ANCHOR_BROWSER_ACTION, false); |
227 CloseBubble(browser()); | 230 if (click_learn_more) { |
| 231 ClickLearnMoreButton(browser()); |
| 232 EXPECT_EQ(3, browser()->tab_strip_model()->count()); |
| 233 } else { |
| 234 CloseBubble(browser()); |
| 235 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 236 } |
228 } | 237 } |
229 | 238 |
230 void ExtensionMessageBubbleBrowserTest::TestControlledHomeBubbleShown() { | 239 void ExtensionMessageBubbleBrowserTest::TestControlledHomeBubbleShown() { |
231 browser()->profile()->GetPrefs()->SetBoolean(prefs::kShowHomeButton, true); | 240 browser()->profile()->GetPrefs()->SetBoolean(prefs::kShowHomeButton, true); |
232 | 241 |
233 const char kHomePage[] = "'homepage': 'https://www.google.com'\n"; | 242 const char kHomePage[] = "'homepage': 'https://www.google.com'\n"; |
234 AddSettingsOverrideExtension(kHomePage); | 243 AddSettingsOverrideExtension(kHomePage); |
235 | 244 |
236 CheckBubbleIsNotPresent(browser(), false, false); | 245 CheckBubbleIsNotPresent(browser(), false, false); |
237 | 246 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 second_browser->window()->Show(); | 378 second_browser->window()->Show(); |
370 base::RunLoop().RunUntilIdle(); | 379 base::RunLoop().RunUntilIdle(); |
371 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true); | 380 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true); |
372 ClickDismissButton(second_browser); | 381 ClickDismissButton(second_browser); |
373 base::RunLoop().RunUntilIdle(); | 382 base::RunLoop().RunUntilIdle(); |
374 CheckBubbleIsNotPresent(browser(), false, false); | 383 CheckBubbleIsNotPresent(browser(), false, false); |
375 // Clicking dismiss should have no affect, so the extension should still be | 384 // Clicking dismiss should have no affect, so the extension should still be |
376 // active. | 385 // active. |
377 EXPECT_TRUE(registry->enabled_extensions().GetByID(id)); | 386 EXPECT_TRUE(registry->enabled_extensions().GetByID(id)); |
378 } | 387 } |
OLD | NEW |