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

Side by Side Diff: chrome/browser/ui/extensions/extension_message_bubble_browsertest.cc

Issue 2086193002: [Extensions UI] Fix a crash when clicking on a bubble's learn more (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Views clicking Created 4 years, 6 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 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/extensions/extension_action_test_util.h" 10 #include "chrome/browser/extensions/extension_action_test_util.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/test_extension_dir.h" 12 #include "chrome/browser/extensions/test_extension_dir.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" 16 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h"
17 #include "chrome/browser/ui/location_bar/location_bar.h" 17 #include "chrome/browser/ui/location_bar/location_bar.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 19 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h"
20 #include "components/omnibox/browser/omnibox_edit_model.h" 22 #include "components/omnibox/browser/omnibox_edit_model.h"
23 #include "content/public/test/browser_test_utils.h"
24 #include "extensions/browser/extension_registry.h"
25 #include "extensions/common/extension.h"
21 #include "extensions/common/feature_switch.h" 26 #include "extensions/common/feature_switch.h"
22 #include "extensions/test/extension_test_message_listener.h" 27 #include "extensions/test/extension_test_message_listener.h"
23 28
24 ExtensionMessageBubbleBrowserTest::ExtensionMessageBubbleBrowserTest() { 29 ExtensionMessageBubbleBrowserTest::ExtensionMessageBubbleBrowserTest() {
25 } 30 }
26 31
27 ExtensionMessageBubbleBrowserTest::~ExtensionMessageBubbleBrowserTest() { 32 ExtensionMessageBubbleBrowserTest::~ExtensionMessageBubbleBrowserTest() {
28 } 33 }
29 34
30 void ExtensionMessageBubbleBrowserTest::SetUpCommandLine( 35 void ExtensionMessageBubbleBrowserTest::SetUpCommandLine(
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 Browser* fourth_browser = new Browser(Browser::CreateParams(profile())); 264 Browser* fourth_browser = new Browser(Browser::CreateParams(profile()));
260 base::RunLoop().RunUntilIdle(); 265 base::RunLoop().RunUntilIdle();
261 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true); 266 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true);
262 // Even though the bubble isn't present on these browser windows, highlighting 267 // Even though the bubble isn't present on these browser windows, highlighting
263 // is per-profile. 268 // is per-profile.
264 CheckBubbleIsNotPresent(browser(), true, true); 269 CheckBubbleIsNotPresent(browser(), true, true);
265 CheckBubbleIsNotPresent(third_browser, true, true); 270 CheckBubbleIsNotPresent(third_browser, true, true);
266 CheckBubbleIsNotPresent(fourth_browser, true, true); 271 CheckBubbleIsNotPresent(fourth_browser, true, true);
267 CloseBubble(second_browser); 272 CloseBubble(second_browser);
268 } 273 }
274
275 void ExtensionMessageBubbleBrowserTest::TestClickingLearnMoreButton() {
276 CheckBubbleIsNotPresent(browser(), false, false);
277 LoadExtension(test_data_dir_.AppendASCII("good_unpacked"));
278 Browser* second_browser = new Browser(Browser::CreateParams(profile()));
279 base::RunLoop().RunUntilIdle();
280 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true);
281 ClickLearnMoreButton(second_browser);
282 base::RunLoop().RunUntilIdle();
283 CheckBubbleIsNotPresent(second_browser, false, false);
284 // The learn more link goes to the chrome://extensions page, so it should be
285 // opened in the active tab.
286 content::WebContents* active_web_contents =
287 second_browser->tab_strip_model()->GetActiveWebContents();
288 content::WaitForLoadStop(active_web_contents);
289 EXPECT_EQ(GURL(chrome::kChromeUIExtensionsURL),
290 active_web_contents->GetLastCommittedURL());
291 }
292
293 void ExtensionMessageBubbleBrowserTest::TestClickingActionButton() {
294 CheckBubbleIsNotPresent(browser(), false, false);
295 const extensions::Extension* extension =
296 LoadExtension(test_data_dir_.AppendASCII("good_unpacked"));
297 extensions::ExtensionRegistry* registry =
298 extensions::ExtensionRegistry::Get(profile());
299 std::string id = extension->id();
300 EXPECT_TRUE(registry->enabled_extensions().GetByID(id));
301 Browser* second_browser = new Browser(Browser::CreateParams(profile()));
302 base::RunLoop().RunUntilIdle();
303 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true);
304 ClickActionButton(second_browser);
305 base::RunLoop().RunUntilIdle();
306 CheckBubbleIsNotPresent(browser(), false, false);
307 // Clicking the action button disabled the extension.
308 EXPECT_FALSE(registry->enabled_extensions().GetByID(id));
309 }
310
311 void ExtensionMessageBubbleBrowserTest::TestClickingDismissButton() {
312 CheckBubbleIsNotPresent(browser(), false, false);
313 const extensions::Extension* extension =
314 LoadExtension(test_data_dir_.AppendASCII("good_unpacked"));
315 extensions::ExtensionRegistry* registry =
316 extensions::ExtensionRegistry::Get(profile());
317 std::string id = extension->id();
318 EXPECT_TRUE(registry->enabled_extensions().GetByID(id));
319 Browser* second_browser = new Browser(Browser::CreateParams(profile()));
320 base::RunLoop().RunUntilIdle();
321 CheckBubble(second_browser, ANCHOR_BROWSER_ACTION, true);
322 ClickDismissButton(second_browser);
323 base::RunLoop().RunUntilIdle();
324 CheckBubbleIsNotPresent(browser(), false, false);
325 // Clicking dismiss should have no affect, so the extension should still be
326 // active.
327 EXPECT_TRUE(registry->enabled_extensions().GetByID(id));
328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698