| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // Tests PPB_VideoSource_Private interface. | 5 // Tests PPB_VideoSource_Private interface. |
| 6 | 6 |
| 7 #include "ppapi/tests/test_video_source.h" | 7 #include "ppapi/tests/test_video_source.h" |
| 8 | 8 |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ppb_video_source_private_interface_->IsVideoSource(video_source)); | 87 ppb_video_source_private_interface_->IsVideoSource(video_source)); |
| 88 | 88 |
| 89 PASS(); | 89 PASS(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 std::string TestVideoSource::TestGetFrame() { | 92 std::string TestVideoSource::TestGetFrame() { |
| 93 std::string js_code; | 93 std::string js_code; |
| 94 js_code += "var test_stream;" | 94 js_code += "var test_stream;" |
| 95 "function gotStream(stream){" | 95 "function gotStream(stream){" |
| 96 " test_stream = stream;" | 96 " test_stream = stream;" |
| 97 " var url = webkitURL.createObjectURL(test_stream);" | 97 " var url = URL.createObjectURL(test_stream);" |
| 98 " var plugin = document.getElementById('plugin');" | 98 " var plugin = document.getElementById('plugin');" |
| 99 " plugin.postMessage(url);" | 99 " plugin.postMessage(url);" |
| 100 "}" | 100 "}" |
| 101 "navigator.webkitGetUserMedia(" | 101 "navigator.webkitGetUserMedia(" |
| 102 "{audio:false, video:true}, gotStream, function() {});"; | 102 "{audio:false, video:true}, gotStream, function() {});"; |
| 103 instance_->EvalScript(js_code); | 103 instance_->EvalScript(js_code); |
| 104 event_.Wait(); | 104 event_.Wait(); |
| 105 | 105 |
| 106 pp::VideoSource_Private video_source(instance_); | 106 pp::VideoSource_Private video_source(instance_); |
| 107 TestCompletionCallback cc1(instance_->pp_instance(), false); | 107 TestCompletionCallback cc1(instance_->pp_instance(), false); |
| 108 cc1.WaitForResult(video_source.Open(stream_url_, cc1.GetCallback())); | 108 cc1.WaitForResult(video_source.Open(stream_url_, cc1.GetCallback())); |
| 109 ASSERT_EQ(PP_OK, cc1.result()); | 109 ASSERT_EQ(PP_OK, cc1.result()); |
| 110 TestCompletionCallbackWithOutput<pp::VideoFrame_Private> cc2( | 110 TestCompletionCallbackWithOutput<pp::VideoFrame_Private> cc2( |
| 111 instance_->pp_instance(), false); | 111 instance_->pp_instance(), false); |
| 112 cc2.WaitForResult(video_source.GetFrame(cc2.GetCallback())); | 112 cc2.WaitForResult(video_source.GetFrame(cc2.GetCallback())); |
| 113 ASSERT_EQ(PP_OK, cc2.result()); | 113 ASSERT_EQ(PP_OK, cc2.result()); |
| 114 const pp::VideoFrame_Private video_frame = cc2.output(); | 114 const pp::VideoFrame_Private video_frame = cc2.output(); |
| 115 ASSERT_FALSE(video_frame.image_data().is_null()); | 115 ASSERT_FALSE(video_frame.image_data().is_null()); |
| 116 | 116 |
| 117 video_source.Close(); | 117 video_source.Close(); |
| 118 | 118 |
| 119 PASS(); | 119 PASS(); |
| 120 } | 120 } |
| 121 | 121 |
| OLD | NEW |