OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Available key systems. | 30 // Available key systems. |
31 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 31 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
32 static const char kExternalClearKeyKeySystem[] = | 32 static const char kExternalClearKeyKeySystem[] = |
33 "org.chromium.externalclearkey"; | 33 "org.chromium.externalclearkey"; |
34 | 34 |
35 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; | 35 static const char kWebMAudioOnly[] = "audio/webm; codecs=\"vorbis\""; |
36 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; | 36 static const char kWebMVideoOnly[] = "video/webm; codecs=\"vp8\""; |
37 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; | 37 static const char kWebMAudioVideo[] = "video/webm; codecs=\"vorbis, vp8\""; |
38 | 38 |
| 39 namespace content { |
39 | 40 |
40 class EncryptedMediaTest | 41 class EncryptedMediaTest : public testing::WithParamInterface<const char*>, |
41 : public testing::WithParamInterface<const char*>, | 42 public ContentBrowserTest { |
42 public content::ContentBrowserTest { | |
43 public: | 43 public: |
44 void TestSimplePlayback(const char* encrypted_media, const char* media_type, | 44 void TestSimplePlayback(const char* encrypted_media, const char* media_type, |
45 const char* key_system, const string16 expectation) { | 45 const char* key_system, const string16 expectation) { |
46 PlayEncryptedMedia("encrypted_media_player.html", encrypted_media, | 46 PlayEncryptedMedia("encrypted_media_player.html", encrypted_media, |
47 media_type, key_system, expectation); | 47 media_type, key_system, expectation); |
48 } | 48 } |
49 | 49 |
50 void TestFrameSizeChange(const char* key_system, const string16 expectation) { | 50 void TestFrameSizeChange(const char* key_system, const string16 expectation) { |
51 PlayEncryptedMedia("encrypted_frame_size_change.html", | 51 PlayEncryptedMedia("encrypted_frame_size_change.html", |
52 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, | 52 "frame_size_change-av-enc-v.webm", kWebMAudioVideo, |
53 key_system, expectation); | 53 key_system, expectation); |
54 } | 54 } |
55 | 55 |
56 void PlayEncryptedMedia(const char* html_page, const char* media_file, | 56 void PlayEncryptedMedia(const char* html_page, const char* media_file, |
57 const char* media_type, const char* key_system, | 57 const char* media_type, const char* key_system, |
58 const string16 expectation) { | 58 const string16 expectation) { |
59 // TODO(shadi): Add non-HTTP tests once src is supported for EME. | 59 // TODO(shadi): Add non-HTTP tests once src is supported for EME. |
60 ASSERT_TRUE(test_server()->Start()); | 60 ASSERT_TRUE(test_server()->Start()); |
61 | 61 |
62 const string16 kError = ASCIIToUTF16("ERROR"); | 62 const string16 kError = ASCIIToUTF16("ERROR"); |
63 const string16 kFailed = ASCIIToUTF16("FAILED"); | 63 const string16 kFailed = ASCIIToUTF16("FAILED"); |
64 GURL player_gurl = test_server()->GetURL(base::StringPrintf( | 64 GURL player_gurl = test_server()->GetURL(base::StringPrintf( |
65 "files/media/%s?keysystem=%s&mediafile=%s&mediatype=%s", html_page, | 65 "files/media/%s?keysystem=%s&mediafile=%s&mediatype=%s", html_page, |
66 key_system, media_file, media_type)); | 66 key_system, media_file, media_type)); |
67 content::TitleWatcher title_watcher(shell()->web_contents(), expectation); | 67 TitleWatcher title_watcher(shell()->web_contents(), expectation); |
68 title_watcher.AlsoWaitForTitle(kError); | 68 title_watcher.AlsoWaitForTitle(kError); |
69 title_watcher.AlsoWaitForTitle(kFailed); | 69 title_watcher.AlsoWaitForTitle(kFailed); |
70 | 70 |
71 content::NavigateToURL(shell(), player_gurl); | 71 NavigateToURL(shell(), player_gurl); |
72 | 72 |
73 string16 final_title = title_watcher.WaitAndGetTitle(); | 73 string16 final_title = title_watcher.WaitAndGetTitle(); |
74 EXPECT_EQ(expectation, final_title); | 74 EXPECT_EQ(expectation, final_title); |
75 | 75 |
76 if (final_title == kFailed) { | 76 if (final_title == kFailed) { |
77 std::string fail_message; | 77 std::string fail_message; |
78 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( | 78 EXPECT_TRUE(ExecuteJavaScriptAndExtractString( |
79 shell()->web_contents()->GetRenderViewHost(), L"", | 79 shell()->web_contents()->GetRenderViewHost(), L"", |
80 L"window.domAutomationController.send(failMessage);", &fail_message)); | 80 L"window.domAutomationController.send(failMessage);", &fail_message)); |
81 LOG(INFO) << "Test failed: " << fail_message; | 81 LOG(INFO) << "Test failed: " << fail_message; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 protected: | 85 protected: |
86 // Registers any CDM plugins not registered by default. | 86 // Registers any CDM plugins not registered by default. |
87 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 87 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
88 command_line->AppendSwitch(switches::kDisableAudio); | 88 command_line->AppendSwitch(switches::kDisableAudio); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 const string16 kExpected = ASCIIToUTF16("ENDED"); | 164 const string16 kExpected = ASCIIToUTF16("ENDED"); |
165 ASSERT_NO_FATAL_FAILURE( | 165 ASSERT_NO_FATAL_FAILURE( |
166 TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo, | 166 TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo, |
167 GetParam(), kExpected)); | 167 GetParam(), kExpected)); |
168 } | 168 } |
169 | 169 |
170 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameChangeVideo) { | 170 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, FrameChangeVideo) { |
171 const string16 kExpected = ASCIIToUTF16("ENDED"); | 171 const string16 kExpected = ASCIIToUTF16("ENDED"); |
172 ASSERT_NO_FATAL_FAILURE(TestFrameSizeChange(GetParam(), kExpected)); | 172 ASSERT_NO_FATAL_FAILURE(TestFrameSizeChange(GetParam(), kExpected)); |
173 } | 173 } |
| 174 |
| 175 } // namespace content |
OLD | NEW |