OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include <algorithm> | 5 #include <algorithm> |
6 #include <cmath> | 6 #include <cmath> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "net/base/rand_callback.h" | 30 #include "net/base/rand_callback.h" |
31 #include "net/udp/udp_socket.h" | 31 #include "net/udp/udp_socket.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
33 | 33 |
34 using media::cast::test::GetFreeLocalPort; | 34 using media::cast::test::GetFreeLocalPort; |
35 | 35 |
36 namespace extensions { | 36 namespace extensions { |
37 | 37 |
38 class CastStreamingApiTest : public ExtensionApiTest { | 38 class CastStreamingApiTest : public ExtensionApiTest { |
39 public: | 39 public: |
40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 40 virtual void SetUpCommandLine(CommandLine* command_line) override { |
41 ExtensionApiTest::SetUpCommandLine(command_line); | 41 ExtensionApiTest::SetUpCommandLine(command_line); |
42 command_line->AppendSwitchASCII( | 42 command_line->AppendSwitchASCII( |
43 extensions::switches::kWhitelistedExtensionID, | 43 extensions::switches::kWhitelistedExtensionID, |
44 "ddchlicdkolnonkihahngkmmmjnjlkkf"); | 44 "ddchlicdkolnonkihahngkmmmjnjlkkf"); |
45 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300"); | 45 command_line->AppendSwitchASCII(::switches::kWindowSize, "300,300"); |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 // Test running the test extension for Cast Mirroring API. | 49 // Test running the test extension for Cast Mirroring API. |
50 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Basics) { | 50 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Basics) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } else { | 148 } else { |
149 LOG(INFO) << "Waiting to encounter " << expected_tones_.size() | 149 LOG(INFO) << "Waiting to encounter " << expected_tones_.size() |
150 << " more tone(s) and " << expected_yuv_colors_.size() | 150 << " more tone(s) and " << expected_yuv_colors_.size() |
151 << " more color(s)."; | 151 << " more color(s)."; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 // Invoked by InProcessReceiver for each received audio frame. | 155 // Invoked by InProcessReceiver for each received audio frame. |
156 virtual void OnAudioFrame(scoped_ptr<media::AudioBus> audio_frame, | 156 virtual void OnAudioFrame(scoped_ptr<media::AudioBus> audio_frame, |
157 const base::TimeTicks& playout_time, | 157 const base::TimeTicks& playout_time, |
158 bool is_continuous) OVERRIDE { | 158 bool is_continuous) override { |
159 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN)); | 159 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN)); |
160 | 160 |
161 if (audio_frame->frames() <= 0) { | 161 if (audio_frame->frames() <= 0) { |
162 NOTREACHED() << "OnAudioFrame called with no samples?!?"; | 162 NOTREACHED() << "OnAudioFrame called with no samples?!?"; |
163 return; | 163 return; |
164 } | 164 } |
165 | 165 |
166 if (done_callback_.is_null() || expected_tones_.empty()) | 166 if (done_callback_.is_null() || expected_tones_.empty()) |
167 return; // No need to waste CPU doing analysis on the signal. | 167 return; // No need to waste CPU doing analysis on the signal. |
168 | 168 |
(...skipping 18 matching lines...) Expand all Loading... |
187 LOG(INFO) << "Heard tone at frequency " << *it << " Hz."; | 187 LOG(INFO) << "Heard tone at frequency " << *it << " Hz."; |
188 expected_tones_.erase(it); | 188 expected_tones_.erase(it); |
189 MaybeRunDoneCallback(); | 189 MaybeRunDoneCallback(); |
190 break; | 190 break; |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 virtual void OnVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, | 195 virtual void OnVideoFrame(const scoped_refptr<media::VideoFrame>& video_frame, |
196 const base::TimeTicks& playout_time, | 196 const base::TimeTicks& playout_time, |
197 bool is_continuous) OVERRIDE { | 197 bool is_continuous) override { |
198 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN)); | 198 DCHECK(cast_env()->CurrentlyOn(media::cast::CastEnvironment::MAIN)); |
199 | 199 |
200 CHECK(video_frame->format() == media::VideoFrame::YV12 || | 200 CHECK(video_frame->format() == media::VideoFrame::YV12 || |
201 video_frame->format() == media::VideoFrame::I420 || | 201 video_frame->format() == media::VideoFrame::I420 || |
202 video_frame->format() == media::VideoFrame::YV12A); | 202 video_frame->format() == media::VideoFrame::YV12A); |
203 | 203 |
204 if (done_callback_.is_null() || expected_yuv_colors_.empty()) | 204 if (done_callback_.is_null() || expected_yuv_colors_.empty()) |
205 return; // No need to waste CPU doing analysis on the frame. | 205 return; // No need to waste CPU doing analysis on the frame. |
206 | 206 |
207 // Take the median value of each plane because the test image will contain a | 207 // Take the median value of each plane because the test image will contain a |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 std::vector<int> expected_tones_; | 309 std::vector<int> expected_tones_; |
310 std::vector<YUVColor> expected_yuv_colors_; | 310 std::vector<YUVColor> expected_yuv_colors_; |
311 base::Closure done_callback_; | 311 base::Closure done_callback_; |
312 | 312 |
313 DISALLOW_COPY_AND_ASSIGN(TestPatternReceiver); | 313 DISALLOW_COPY_AND_ASSIGN(TestPatternReceiver); |
314 }; | 314 }; |
315 | 315 |
316 } // namespace | 316 } // namespace |
317 | 317 |
318 class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest { | 318 class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest { |
319 virtual void SetUp() OVERRIDE { | 319 virtual void SetUp() override { |
320 EnablePixelOutput(); | 320 EnablePixelOutput(); |
321 CastStreamingApiTest::SetUp(); | 321 CastStreamingApiTest::SetUp(); |
322 } | 322 } |
323 | 323 |
324 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 324 virtual void SetUpCommandLine(CommandLine* command_line) override { |
325 command_line->AppendSwitchASCII(::switches::kWindowSize, "128,128"); | 325 command_line->AppendSwitchASCII(::switches::kWindowSize, "128,128"); |
326 CastStreamingApiTest::SetUpCommandLine(command_line); | 326 CastStreamingApiTest::SetUpCommandLine(command_line); |
327 } | 327 } |
328 }; | 328 }; |
329 | 329 |
330 // Tests the Cast streaming API and its basic functionality end-to-end. An | 330 // Tests the Cast streaming API and its basic functionality end-to-end. An |
331 // extension subtest is run to generate test content, capture that content, and | 331 // extension subtest is run to generate test content, capture that content, and |
332 // use the API to send it out. At the same time, this test launches an | 332 // use the API to send it out. At the same time, this test launches an |
333 // in-process Cast receiver, listening on a localhost UDP socket, to receive the | 333 // in-process Cast receiver, listening on a localhost UDP socket, to receive the |
334 // content and check whether it matches expectations. | 334 // content and check whether it matches expectations. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 | 391 |
392 delete receiver; | 392 delete receiver; |
393 cast_environment->Shutdown(); | 393 cast_environment->Shutdown(); |
394 } | 394 } |
395 | 395 |
396 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { | 396 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { |
397 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); | 397 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); |
398 } | 398 } |
399 | 399 |
400 } // namespace extensions | 400 } // namespace extensions |
OLD | NEW |