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
3 // found in the LICENSE file.
5 #include "chrome/browser/devtools/device/adb/adb_device_provider.h"
6 #include "chrome/browser/devtools/device/adb/mock_adb_server.h"
7 #include "chrome/browser/devtools/device/devtools_android_bridge.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "chrome/test/base/web_ui_browser_test.h"
13 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/browser_test_utils.h"
17 using content::WebContents
;
21 const char kSharedWorkerTestPage
[] =
22 "files/workers/workers_ui_shared_worker.html";
23 const char kSharedWorkerJs
[] =
24 "files/workers/workers_ui_shared_worker.js";
26 class InspectUITest
: public WebUIBrowserTest
{
30 void SetUpOnMainThread() override
{
31 WebUIBrowserTest::SetUpOnMainThread();
32 AddLibrary(base::FilePath(FILE_PATH_LITERAL("inspect_ui_test.js")));
36 DISALLOW_COPY_AND_ASSIGN(InspectUITest
);
39 IN_PROC_BROWSER_TEST_F(InspectUITest
, InspectUIPage
) {
40 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));
41 ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
43 new base::StringValue("#pages"),
44 new base::StringValue("populateWebContentsTargets"),
45 new base::StringValue(chrome::kChromeUIInspectURL
)));
48 IN_PROC_BROWSER_TEST_F(InspectUITest
, SharedWorker
) {
49 ASSERT_TRUE(test_server()->Start());
50 GURL url
= test_server()->GetURL(kSharedWorkerTestPage
);
51 ui_test_utils::NavigateToURL(browser(), url
);
53 ui_test_utils::NavigateToURLWithDisposition(
55 GURL(chrome::kChromeUIInspectURL
),
57 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION
);
59 ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
61 new base::StringValue("#workers"),
62 new base::StringValue("populateWorkerTargets"),
63 new base::StringValue(kSharedWorkerJs
)));
65 ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest(
67 new base::StringValue("#pages"),
68 new base::StringValue("populateWebContentsTargets"),
69 new base::StringValue(kSharedWorkerTestPage
)));
72 IN_PROC_BROWSER_TEST_F(InspectUITest
, AndroidTargets
) {
73 DevToolsAndroidBridge
* android_bridge
=
74 DevToolsAndroidBridge::Factory::GetForProfile(browser()->profile());
75 AndroidDeviceManager::DeviceProviders providers
;
76 providers
.push_back(new AdbDeviceProvider());
77 android_bridge
->set_device_providers_for_test(providers
);
81 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));
83 ASSERT_TRUE(WebUIBrowserTest::RunJavascriptAsyncTest("testAdbTargetsListed"));
88 IN_PROC_BROWSER_TEST_F(InspectUITest
, ReloadCrash
) {
89 ASSERT_TRUE(test_server()->Start());
90 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));
91 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIInspectURL
));