1 // Copyright (c) 2013 Intel Corporation. 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 "base/command_line.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "xwalk/runtime/browser/runtime.h"
8 #include "xwalk/test/base/in_process_browser_test.h"
9 #include "xwalk/test/base/xwalk_test_utils.h"
10 #include "content/public/common/content_switches.h"
11 #include "content/public/browser/navigation_entry.h"
12 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/test_utils.h"
14 #include "content/public/browser/web_contents.h"
15 #include "net/base/net_util.h"
16 #include "testing/gmock/include/gmock/gmock.h"
20 Runtime* CreateWithDefaultWindow(
21 xwalk::RuntimeContext* runtime_context, const GURL& url,
22 Runtime::Observer* observer = NULL) {
23 Runtime* runtime = Runtime::Create(runtime_context, observer);
24 runtime->LoadURL(url);
25 #if !defined(OS_ANDROID)
26 xwalk::RuntimeUIStrategy ui_strategy;
27 xwalk::NativeAppWindow::CreateParams params;
28 ui_strategy.Show(runtime, params);
34 class XWalkDevToolsTest : public InProcessBrowserTest {
36 XWalkDevToolsTest() {}
37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
38 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222");
39 GURL url = xwalk_test_utils::GetTestURL(
40 base::FilePath(), base::FilePath().AppendASCII("test.html"));
41 command_line->AppendArg(url.spec());
45 IN_PROC_BROWSER_TEST_F(XWalkDevToolsTest, RemoteDebugging) {
46 GURL localhost_url("http://127.0.0.1:9222");
47 Runtime* debugging_host = CreateWithDefaultWindow(
48 GetRuntimeContext(), localhost_url, runtime_registry());
49 content::WaitForLoadStop(debugging_host->web_contents());
50 base::string16 real_title = debugging_host->web_contents()->GetTitle();
51 base::string16 expected_title = base::ASCIIToUTF16("XWalk Remote Debugging");
52 EXPECT_EQ(expected_title, real_title);