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

Side by Side Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 18192003: Add tests for ShellWindowLinkDelegate::OpenURLFromTab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "apps/shell_window.h" 5 #include "apps/shell_window.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/test_timeouts.h" 12 #include "base/test/test_timeouts.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/automation/automation_util.h" 15 #include "chrome/browser/automation/automation_util.h"
16 #include "chrome/browser/devtools/devtools_window.h" 16 #include "chrome/browser/devtools/devtools_window.h"
17 #include "chrome/browser/extensions/api/permissions/permissions_api.h" 17 #include "chrome/browser/extensions/api/permissions/permissions_api.h"
18 #include "chrome/browser/extensions/component_loader.h" 18 #include "chrome/browser/extensions/component_loader.h"
19 #include "chrome/browser/extensions/event_names.h" 19 #include "chrome/browser/extensions/event_names.h"
20 #include "chrome/browser/extensions/event_router.h" 20 #include "chrome/browser/extensions/event_router.h"
21 #include "chrome/browser/extensions/extension_browsertest.h" 21 #include "chrome/browser/extensions/extension_browsertest.h"
22 #include "chrome/browser/extensions/extension_prefs.h" 22 #include "chrome/browser/extensions/extension_prefs.h"
23 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/extension_system.h" 24 #include "chrome/browser/extensions/extension_system.h"
25 #include "chrome/browser/extensions/extension_test_message_listener.h" 25 #include "chrome/browser/extensions/extension_test_message_listener.h"
26 #include "chrome/browser/extensions/platform_app_browsertest_util.h" 26 #include "chrome/browser/extensions/platform_app_browsertest_util.h"
27 #include "chrome/browser/extensions/platform_app_launcher.h" 27 #include "chrome/browser/extensions/platform_app_launcher.h"
28 #include "chrome/browser/extensions/shell_window_registry.h" 28 #include "chrome/browser/extensions/shell_window_registry.h"
29 #include "chrome/browser/tab_contents/render_view_context_menu.h" 29 #include "chrome/browser/tab_contents/render_view_context_menu.h"
30 #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
30 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/extensions/application_launch.h" 32 #include "chrome/browser/ui/extensions/application_launch.h"
32 #include "chrome/browser/ui/extensions/native_app_window.h" 33 #include "chrome/browser/ui/extensions/native_app_window.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 34 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/common/chrome_notification_types.h" 35 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/chrome_switches.h" 36 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
37 #include "chrome/test/base/ui_test_utils.h" 38 #include "chrome/test/base/ui_test_utils.h"
38 #include "components/user_prefs/pref_registry_syncable.h" 39 #include "components/user_prefs/pref_registry_syncable.h"
39 #include "components/web_modal/web_contents_modal_dialog_manager.h" 40 #include "components/web_modal/web_contents_modal_dialog_manager.h"
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 600 }
600 601
601 // Test that platform apps can use the chrome.fileSystem.getDisplayPath 602 // Test that platform apps can use the chrome.fileSystem.getDisplayPath
602 // function to get the native file system path of a file they are launched with. 603 // function to get the native file system path of a file they are launched with.
603 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) { 604 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) {
604 SetCommandLineArg(kTestFilePath); 605 SetCommandLineArg(kTestFilePath);
605 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path")) 606 ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path"))
606 << message_; 607 << message_;
607 } 608 }
608 609
610 // Test that ShellWindowLinkDelegate::OpenURLFromTab doesn't crash. This code
611 // relies on the WebContents implementation not dereferencing the Source
612 // WebContents after ShellWindowLinkDelegate frees it.
613 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExternalOpenLink) {
614 chrome::ChromeShellWindowDelegate::EnableExternalOpenForTesting();
615 ASSERT_TRUE(RunPlatformAppTest("platform_apps/external_open_link"));
616 chrome::ChromeShellWindowDelegate::DisableExternalOpenForTesting();
617 }
618
Ken Rockot(use gerrit already) 2013/07/01 15:02:54 First, this is not the right test for the associat
zhchbin 2013/07/02 08:59:06 Sorry for my mistake first of all. However, when d
609 #endif // defined(OS_CHROMEOS) 619 #endif // defined(OS_CHROMEOS)
610 620
611 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) { 621 IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, OpenLink) {
612 ASSERT_TRUE(StartEmbeddedTestServer()); 622 ASSERT_TRUE(StartEmbeddedTestServer());
613 content::WindowedNotificationObserver observer( 623 content::WindowedNotificationObserver observer(
614 chrome::NOTIFICATION_TAB_ADDED, 624 chrome::NOTIFICATION_TAB_ADDED,
615 content::Source<content::WebContentsDelegate>(browser())); 625 content::Source<content::WebContentsDelegate>(browser()));
616 LoadAndLaunchPlatformApp("open_link"); 626 LoadAndLaunchPlatformApp("open_link");
617 observer.Wait(); 627 observer.Wait();
618 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 628 ASSERT_EQ(2, browser()->tab_strip_model()->count());
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1088
1079 while (!ContainsKey(opener_app_ids_, file_manager->id())) { 1089 while (!ContainsKey(opener_app_ids_, file_manager->id())) {
1080 content::RunAllPendingInMessageLoop(); 1090 content::RunAllPendingInMessageLoop();
1081 } 1091 }
1082 } 1092 }
1083 1093
1084 #endif // defined(OS_CHROMEOS) 1094 #endif // defined(OS_CHROMEOS)
1085 1095
1086 1096
1087 } // namespace extensions 1097 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698