| 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 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/float_util.h" | 9 #include "base/float_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "chrome/browser/extensions/extension_apitest.h" | 14 #include "chrome/browser/extensions/extension_apitest.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "extensions/common/switches.h" |
| 17 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
| 18 #include "media/base/video_frame.h" | 19 #include "media/base/video_frame.h" |
| 19 #include "media/cast/cast_config.h" | 20 #include "media/cast/cast_config.h" |
| 20 #include "media/cast/cast_environment.h" | 21 #include "media/cast/cast_environment.h" |
| 21 #include "media/cast/test/utility/audio_utility.h" | 22 #include "media/cast/test/utility/audio_utility.h" |
| 22 #include "media/cast/test/utility/default_config.h" | 23 #include "media/cast/test/utility/default_config.h" |
| 23 #include "media/cast/test/utility/in_process_receiver.h" | 24 #include "media/cast/test/utility/in_process_receiver.h" |
| 24 #include "media/cast/test/utility/standalone_cast_environment.h" | 25 #include "media/cast/test/utility/standalone_cast_environment.h" |
| 25 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 26 #include "net/base/net_util.h" | 27 #include "net/base/net_util.h" |
| 27 #include "net/base/rand_callback.h" | 28 #include "net/base/rand_callback.h" |
| 28 #include "net/udp/udp_socket.h" | 29 #include "net/udp/udp_socket.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 31 |
| 31 namespace extensions { | 32 namespace extensions { |
| 32 | 33 |
| 33 class CastStreamingApiTest : public ExtensionApiTest { | 34 class CastStreamingApiTest : public ExtensionApiTest { |
| 34 public: | 35 public: |
| 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 36 ExtensionApiTest::SetUpCommandLine(command_line); | 37 ExtensionApiTest::SetUpCommandLine(command_line); |
| 37 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, | 38 command_line->AppendSwitchASCII( |
| 38 "ddchlicdkolnonkihahngkmmmjnjlkkf"); | 39 extensions::switches::kWhitelistedExtensionID, |
| 40 "ddchlicdkolnonkihahngkmmmjnjlkkf"); |
| 39 } | 41 } |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 // Test running the test extension for Cast Mirroring API. | 44 // Test running the test extension for Cast Mirroring API. |
| 43 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Basics) { | 45 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Basics) { |
| 44 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "basics.html")) << message_; | 46 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "basics.html")) << message_; |
| 45 } | 47 } |
| 46 | 48 |
| 47 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Stats) { | 49 IN_PROC_BROWSER_TEST_F(CastStreamingApiTest, Stats) { |
| 48 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "stats.html")) << message_; | 50 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "stats.html")) << message_; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 262 |
| 261 } // namespace | 263 } // namespace |
| 262 | 264 |
| 263 class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest { | 265 class CastStreamingApiTestWithPixelOutput : public CastStreamingApiTest { |
| 264 virtual void SetUp() OVERRIDE { | 266 virtual void SetUp() OVERRIDE { |
| 265 EnablePixelOutput(); | 267 EnablePixelOutput(); |
| 266 CastStreamingApiTest::SetUp(); | 268 CastStreamingApiTest::SetUp(); |
| 267 } | 269 } |
| 268 | 270 |
| 269 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 271 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 270 command_line->AppendSwitchASCII(switches::kWindowSize, "128,128"); | 272 command_line->AppendSwitchASCII(::switches::kWindowSize, "128,128"); |
| 271 CastStreamingApiTest::SetUpCommandLine(command_line); | 273 CastStreamingApiTest::SetUpCommandLine(command_line); |
| 272 } | 274 } |
| 273 }; | 275 }; |
| 274 | 276 |
| 275 // Tests the Cast streaming API and its basic functionality end-to-end. An | 277 // Tests the Cast streaming API and its basic functionality end-to-end. An |
| 276 // extension subtest is run to generate test content, capture that content, and | 278 // extension subtest is run to generate test content, capture that content, and |
| 277 // use the API to send it out. At the same time, this test launches an | 279 // use the API to send it out. At the same time, this test launches an |
| 278 // in-process Cast receiver, listening on a localhost UDP socket, to receive the | 280 // in-process Cast receiver, listening on a localhost UDP socket, to receive the |
| 279 // content and check whether it matches expectations. | 281 // content and check whether it matches expectations. |
| 280 // | 282 // |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 // (see http://crbug.com/349786): | 333 // (see http://crbug.com/349786): |
| 332 // receiver->DestroySoon(); | 334 // receiver->DestroySoon(); |
| 333 cast_environment->Shutdown(); | 335 cast_environment->Shutdown(); |
| 334 } | 336 } |
| 335 | 337 |
| 336 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { | 338 IN_PROC_BROWSER_TEST_F(CastStreamingApiTestWithPixelOutput, RtpStreamError) { |
| 337 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); | 339 ASSERT_TRUE(RunExtensionSubtest("cast_streaming", "rtp_stream_error.html")); |
| 338 } | 340 } |
| 339 | 341 |
| 340 } // namespace extensions | 342 } // namespace extensions |
| OLD | NEW |