OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/test/webrtc_content_browsertest_base.h" | 5 #include "content/test/webrtc_content_browsertest_base.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // doesn't have other interfaces available. | 26 // doesn't have other interfaces available. |
27 CommandLine::ForCurrentProcess()->AppendSwitch( | 27 CommandLine::ForCurrentProcess()->AppendSwitch( |
28 switches::kAllowLoopbackInPeerConnection); | 28 switches::kAllowLoopbackInPeerConnection); |
29 } | 29 } |
30 | 30 |
31 void WebRtcContentBrowserTest::SetUp() { | 31 void WebRtcContentBrowserTest::SetUp() { |
32 EnablePixelOutput(); | 32 EnablePixelOutput(); |
33 ContentBrowserTest::SetUp(); | 33 ContentBrowserTest::SetUp(); |
34 } | 34 } |
35 | 35 |
36 bool WebRtcContentBrowserTest::ExecuteJavascript( | |
37 const std::string& javascript) { | |
38 return ExecuteScript(shell()->web_contents(), javascript); | |
39 } | |
40 | |
41 // Executes |javascript|. The script is required to use | 36 // Executes |javascript|. The script is required to use |
42 // window.domAutomationController.send to send a string value back to here. | 37 // window.domAutomationController.send to send a string value back to here. |
43 std::string WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult( | 38 std::string WebRtcContentBrowserTest::ExecuteJavascriptAndReturnResult( |
44 const std::string& javascript) { | 39 const std::string& javascript) { |
45 std::string result; | 40 std::string result; |
46 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(), | 41 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(), |
47 javascript, | 42 javascript, |
48 &result)); | 43 &result)); |
49 return result; | 44 return result; |
50 } | 45 } |
51 | 46 |
52 void WebRtcContentBrowserTest::ExpectTitle( | 47 void WebRtcContentBrowserTest::ExecuteJavascriptAndWaitForOk( |
53 const std::string& expected_title) const { | 48 const std::string& javascript) { |
54 base::string16 expected_title16(base::ASCIIToUTF16(expected_title)); | 49 std::string result = ExecuteJavascriptAndReturnResult(javascript); |
55 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 50 if (result != "OK") { |
56 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 51 printf("From javascript: %s", result.c_str()); |
57 } | 52 FAIL(); |
| 53 } |
| 54 } |
58 | 55 |
59 std::string WebRtcContentBrowserTest::GenerateGetUserMediaCall( | 56 std::string WebRtcContentBrowserTest::GenerateGetUserMediaCall( |
60 const char* function_name, | 57 const char* function_name, |
61 int min_width, | 58 int min_width, |
62 int max_width, | 59 int max_width, |
63 int min_height, | 60 int min_height, |
64 int max_height, | 61 int max_height, |
65 int min_frame_rate, | 62 int min_frame_rate, |
66 int max_frame_rate) const { | 63 int max_frame_rate) const { |
67 return base::StringPrintf( | 64 return base::StringPrintf( |
68 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, " | 65 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, " |
69 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, " | 66 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, " |
70 "optional: []}});", | 67 "optional: []}});", |
71 function_name, | 68 function_name, |
72 min_width, | 69 min_width, |
73 max_width, | 70 max_width, |
74 min_height, | 71 min_height, |
75 max_height, | 72 max_height, |
76 min_frame_rate, | 73 min_frame_rate, |
77 max_frame_rate); | 74 max_frame_rate); |
78 } | 75 } |
79 | 76 |
80 } // namespace content | 77 } // namespace content |
OLD | NEW |