| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/debug/trace_event_impl.h" | 6 #include "base/debug/trace_event_impl.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 EXPECT_EQ(expected_result, ExecuteJavascriptAndReturnResult(command)); | 193 EXPECT_EQ(expected_result, ExecuteJavascriptAndReturnResult(command)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void GetInputDevices(std::vector<std::string>* audio_ids, | 196 void GetInputDevices(std::vector<std::string>* audio_ids, |
| 197 std::vector<std::string>* video_ids) { | 197 std::vector<std::string>* video_ids) { |
| 198 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 198 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 199 NavigateToURL(shell(), url); | 199 NavigateToURL(shell(), url); |
| 200 | 200 |
| 201 std::string devices_as_json = ExecuteJavascriptAndReturnResult( | 201 std::string devices_as_json = ExecuteJavascriptAndReturnResult( |
| 202 "getMediaDevices()"); | 202 "getSources()"); |
| 203 EXPECT_FALSE(devices_as_json.empty()); | 203 EXPECT_FALSE(devices_as_json.empty()); |
| 204 | 204 |
| 205 int error_code; | 205 int error_code; |
| 206 std::string error_message; | 206 std::string error_message; |
| 207 scoped_ptr<base::Value> value( | 207 scoped_ptr<base::Value> value( |
| 208 base::JSONReader::ReadAndReturnError(devices_as_json, | 208 base::JSONReader::ReadAndReturnError(devices_as_json, |
| 209 base::JSON_ALLOW_TRAILING_COMMAS, | 209 base::JSON_ALLOW_TRAILING_COMMAS, |
| 210 &error_code, | 210 &error_code, |
| 211 &error_message)); | 211 &error_message)); |
| 212 | 212 |
| 213 ASSERT_TRUE(value.get() != NULL) << error_message; | 213 ASSERT_TRUE(value.get() != NULL) << error_message; |
| 214 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); | 214 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); |
| 215 | 215 |
| 216 base::ListValue* values; | 216 base::ListValue* values; |
| 217 ASSERT_TRUE(value->GetAsList(&values)); | 217 ASSERT_TRUE(value->GetAsList(&values)); |
| 218 | 218 |
| 219 for (base::ListValue::iterator it = values->begin(); | 219 for (base::ListValue::iterator it = values->begin(); |
| 220 it != values->end(); ++it) { | 220 it != values->end(); ++it) { |
| 221 const base::DictionaryValue* dict; | 221 const base::DictionaryValue* dict; |
| 222 std::string kind; | 222 std::string kind; |
| 223 std::string device_id; | 223 std::string device_id; |
| 224 ASSERT_TRUE((*it)->GetAsDictionary(&dict)); | 224 ASSERT_TRUE((*it)->GetAsDictionary(&dict)); |
| 225 ASSERT_TRUE(dict->GetString("kind", &kind)); | 225 ASSERT_TRUE(dict->GetString("kind", &kind)); |
| 226 ASSERT_TRUE(dict->GetString("deviceId", &device_id)); | 226 ASSERT_TRUE(dict->GetString("id", &device_id)); |
| 227 ASSERT_FALSE(device_id.empty()); | 227 ASSERT_FALSE(device_id.empty()); |
| 228 EXPECT_TRUE(kind == "audioinput" || kind == "videoinput" || | 228 EXPECT_TRUE(kind == "audio" || kind == "video"); |
| 229 kind == "audiooutput"); | 229 if (kind == "audio") { |
| 230 if (kind == "audioinput") { | |
| 231 audio_ids->push_back(device_id); | 230 audio_ids->push_back(device_id); |
| 232 } else if (kind == "videoinput") { | 231 } else if (kind == "video") { |
| 233 video_ids->push_back(device_id); | 232 video_ids->push_back(device_id); |
| 234 } | 233 } |
| 235 // We ignore audio output. | |
| 236 } | 234 } |
| 237 ASSERT_FALSE(audio_ids->empty()); | 235 ASSERT_FALSE(audio_ids->empty()); |
| 238 ASSERT_FALSE(video_ids->empty()); | 236 ASSERT_FALSE(video_ids->empty()); |
| 239 } | 237 } |
| 240 | 238 |
| 241 private: | 239 private: |
| 242 base::debug::TraceLog* trace_log_; | 240 base::debug::TraceLog* trace_log_; |
| 243 scoped_refptr<base::RefCountedString> recorded_trace_data_; | 241 scoped_refptr<base::RefCountedString> recorded_trace_data_; |
| 244 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 242 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 245 }; | 243 }; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 {640, 640, 360, 360, 10, 30}, | 625 {640, 640, 360, 360, 10, 30}, |
| 628 {640, 640, 480, 480, 10, 30}, | 626 {640, 640, 480, 480, 10, 30}, |
| 629 {960, 960, 720, 720, 10, 30}, | 627 {960, 960, 720, 720, 10, 30}, |
| 630 {1280, 1280, 720, 720, 10, 30}}; | 628 {1280, 1280, 720, 720, 10, 30}}; |
| 631 | 629 |
| 632 INSTANTIATE_TEST_CASE_P(UserMedia, | 630 INSTANTIATE_TEST_CASE_P(UserMedia, |
| 633 WebRtcConstraintsBrowserTest, | 631 WebRtcConstraintsBrowserTest, |
| 634 testing::ValuesIn(kAllUserMediaSizes)); | 632 testing::ValuesIn(kAllUserMediaSizes)); |
| 635 | 633 |
| 636 } // namespace content | 634 } // namespace content |
| OLD | NEW |