OLD | NEW |
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 "base/path_service.h" | 5 #include "base/path_service.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
8 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" | 8 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_function_test_utils.h" | 10 #include "chrome/browser/extensions/extension_function_test_utils.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 dir = dir.AppendASCII("extensions") | 38 dir = dir.AppendASCII("extensions") |
39 .AppendASCII("platform_apps") | 39 .AppendASCII("platform_apps") |
40 .AppendASCII("minimal"); | 40 .AppendASCII("minimal"); |
41 | 41 |
42 // Load and launch a platform app. | 42 // Load and launch a platform app. |
43 const Extension* app = LoadAndLaunchApp(dir); | 43 const Extension* app = LoadAndLaunchApp(dir); |
44 | 44 |
45 // Get the info about the app, including the inspectable views. | 45 // Get the info about the app, including the inspectable views. |
46 scoped_refptr<UIThreadExtensionFunction> function( | 46 scoped_refptr<UIThreadExtensionFunction> function( |
47 new api::DeveloperPrivateGetExtensionInfoFunction()); | 47 new api::DeveloperPrivateGetExtensionInfoFunction()); |
48 scoped_ptr<base::Value> result( | 48 std::unique_ptr<base::Value> result( |
49 extension_function_test_utils::RunFunctionAndReturnSingleResult( | 49 extension_function_test_utils::RunFunctionAndReturnSingleResult( |
50 function.get(), base::StringPrintf("[\"%s\"]", app->id().c_str()), | 50 function.get(), base::StringPrintf("[\"%s\"]", app->id().c_str()), |
51 browser())); | 51 browser())); |
52 ASSERT_TRUE(result); | 52 ASSERT_TRUE(result); |
53 scoped_ptr<api::developer_private::ExtensionInfo> info = | 53 std::unique_ptr<api::developer_private::ExtensionInfo> info = |
54 api::developer_private::ExtensionInfo::FromValue(*result); | 54 api::developer_private::ExtensionInfo::FromValue(*result); |
55 ASSERT_TRUE(info); | 55 ASSERT_TRUE(info); |
56 | 56 |
57 // There should be two inspectable views - the background page and the app | 57 // There should be two inspectable views - the background page and the app |
58 // window. Find the app window. | 58 // window. Find the app window. |
59 ASSERT_EQ(2u, info->views.size()); | 59 ASSERT_EQ(2u, info->views.size()); |
60 const api::developer_private::ExtensionView* window_view = nullptr; | 60 const api::developer_private::ExtensionView* window_view = nullptr; |
61 for (const auto& view : info->views) { | 61 for (const auto& view : info->views) { |
62 if (view.type == api::developer_private::VIEW_TYPE_APP_WINDOW) { | 62 if (view.type == api::developer_private::VIEW_TYPE_APP_WINDOW) { |
63 window_view = &view; | 63 window_view = &view; |
(...skipping 28 matching lines...) Expand all Loading... |
92 .AppendASCII("v1")); | 92 .AppendASCII("v1")); |
93 ASSERT_TRUE(extension); | 93 ASSERT_TRUE(extension); |
94 | 94 |
95 // Open the embedded options page. | 95 // Open the embedded options page. |
96 ASSERT_TRUE(ExtensionTabUtil::OpenOptionsPage(extension, browser())); | 96 ASSERT_TRUE(ExtensionTabUtil::OpenOptionsPage(extension, browser())); |
97 WaitForExtensionNotIdle(extension->id()); | 97 WaitForExtensionNotIdle(extension->id()); |
98 | 98 |
99 // Get the info about the extension, including the inspectable views. | 99 // Get the info about the extension, including the inspectable views. |
100 scoped_refptr<UIThreadExtensionFunction> function( | 100 scoped_refptr<UIThreadExtensionFunction> function( |
101 new api::DeveloperPrivateGetExtensionInfoFunction()); | 101 new api::DeveloperPrivateGetExtensionInfoFunction()); |
102 scoped_ptr<base::Value> result( | 102 std::unique_ptr<base::Value> result( |
103 extension_function_test_utils::RunFunctionAndReturnSingleResult( | 103 extension_function_test_utils::RunFunctionAndReturnSingleResult( |
104 function.get(), | 104 function.get(), |
105 base::StringPrintf("[\"%s\"]", extension->id().c_str()), browser())); | 105 base::StringPrintf("[\"%s\"]", extension->id().c_str()), browser())); |
106 ASSERT_TRUE(result); | 106 ASSERT_TRUE(result); |
107 scoped_ptr<api::developer_private::ExtensionInfo> info = | 107 std::unique_ptr<api::developer_private::ExtensionInfo> info = |
108 api::developer_private::ExtensionInfo::FromValue(*result); | 108 api::developer_private::ExtensionInfo::FromValue(*result); |
109 ASSERT_TRUE(info); | 109 ASSERT_TRUE(info); |
110 | 110 |
111 // The embedded options page should show up. | 111 // The embedded options page should show up. |
112 ASSERT_EQ(1u, info->views.size()); | 112 ASSERT_EQ(1u, info->views.size()); |
113 const api::developer_private::ExtensionView& view = info->views[0]; | 113 const api::developer_private::ExtensionView& view = info->views[0]; |
114 ASSERT_EQ(api::developer_private::VIEW_TYPE_EXTENSION_GUEST, view.type); | 114 ASSERT_EQ(api::developer_private::VIEW_TYPE_EXTENSION_GUEST, view.type); |
115 | 115 |
116 // Inspect the embedded options page. | 116 // Inspect the embedded options page. |
117 function = new api::DeveloperPrivateOpenDevToolsFunction(); | 117 function = new api::DeveloperPrivateOpenDevToolsFunction(); |
118 extension_function_test_utils::RunFunction( | 118 extension_function_test_utils::RunFunction( |
119 function.get(), | 119 function.get(), |
120 base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", | 120 base::StringPrintf("[{\"renderViewId\": %d, \"renderProcessId\": %d}]", |
121 view.render_view_id, view.render_process_id), | 121 view.render_view_id, view.render_process_id), |
122 browser(), extension_function_test_utils::NONE); | 122 browser(), extension_function_test_utils::NONE); |
123 | 123 |
124 // Verify that dev tools opened. | 124 // Verify that dev tools opened. |
125 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 125 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |
126 view.render_process_id, view.render_view_id); | 126 view.render_process_id, view.render_view_id); |
127 ASSERT_TRUE(rfh); | 127 ASSERT_TRUE(rfh); |
128 content::WebContents* wc = content::WebContents::FromRenderFrameHost(rfh); | 128 content::WebContents* wc = content::WebContents::FromRenderFrameHost(rfh); |
129 ASSERT_TRUE(wc); | 129 ASSERT_TRUE(wc); |
130 EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents(wc)); | 130 EXPECT_TRUE(DevToolsWindow::GetInstanceForInspectedWebContents(wc)); |
131 } | 131 } |
132 | 132 |
133 } // namespace extensions | 133 } // namespace extensions |
OLD | NEW |