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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "content/browser/web_contents/web_contents_impl.h" | 12 #include "content/browser/web_contents/web_contents_impl.h" |
13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
15 #include "content/shell/shell.h" | 15 #include "content/shell/shell.h" |
16 #include "content/test/content_browser_test.h" | 16 #include "content/test/content_browser_test.h" |
17 #include "content/test/content_browser_test_utils.h" | 17 #include "content/test/content_browser_test_utils.h" |
18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
19 #include "webkit/media/crypto/key_systems.h" | 19 #include "webkit/media/crypto/key_systems.h" |
20 | 20 |
| 21 namespace content { |
| 22 |
21 // Platform-specific filename relative to the chrome executable. | 23 // Platform-specific filename relative to the chrome executable. |
22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
23 static const wchar_t kLibraryName[] = L"clearkeycdmplugin.dll"; | 25 const wchar_t kLibraryName[] = L"clearkeycdmplugin.dll"; |
24 #elif defined(OS_MACOSX) | 26 #elif defined(OS_MACOSX) |
25 static const char kLibraryName[] = "clearkeycdmplugin.plugin"; | 27 const char kLibraryName[] = "clearkeycdmplugin.plugin"; |
26 #elif defined(OS_POSIX) | 28 #elif defined(OS_POSIX) |
27 static const char kLibraryName[] = "libclearkeycdmplugin.so"; | 29 const char kLibraryName[] = "libclearkeycdmplugin.so"; |
28 #endif | 30 #endif |
29 | 31 |
30 // Available key systems. | 32 // Available key systems. |
31 static const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; | 33 const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey"; |
32 static const char kExternalClearKeyKeySystem[] = | 34 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; |
33 "org.chromium.externalclearkey"; | |
34 | 35 |
35 | 36 class EncryptedMediaTest : public testing::WithParamInterface<const char*>, |
36 class EncryptedMediaTest | 37 public ContentBrowserTest { |
37 : public testing::WithParamInterface<const char*>, | |
38 public content::ContentBrowserTest { | |
39 public: | 38 public: |
40 void TestSimplePlayback(const char* encrypted_video, const char* key_system, | 39 void TestSimplePlayback(const char* encrypted_video, const char* key_system, |
41 const string16 expectation) { | 40 const string16 expectation) { |
42 PlayEncryptedMedia("encrypted_media_player.html", encrypted_video, | 41 PlayEncryptedMedia("encrypted_media_player.html", encrypted_video, |
43 key_system, expectation); | 42 key_system, expectation); |
44 } | 43 } |
45 | 44 |
46 void TestFrameSizeChange(const char* key_system, const string16 expectation) { | 45 void TestFrameSizeChange(const char* key_system, const string16 expectation) { |
47 PlayEncryptedMedia("encrypted_frame_size_change.html", | 46 PlayEncryptedMedia("encrypted_frame_size_change.html", |
48 "frame_size_change-av-enc-v.webm", key_system, | 47 "frame_size_change-av-enc-v.webm", key_system, |
49 expectation); | 48 expectation); |
50 } | 49 } |
51 | 50 |
52 void PlayEncryptedMedia(const char* html_page, const char* media_file, | 51 void PlayEncryptedMedia(const char* html_page, const char* media_file, |
53 const char* key_system, const string16 expectation) { | 52 const char* key_system, const string16 expectation) { |
54 // TODO(shadi): Add non-HTTP tests once src is supported for EME. | 53 // TODO(shadi): Add non-HTTP tests once src is supported for EME. |
55 ASSERT_TRUE(test_server()->Start()); | 54 ASSERT_TRUE(test_server()->Start()); |
56 | 55 |
57 const string16 kError = ASCIIToUTF16("ERROR"); | 56 const string16 kError = ASCIIToUTF16("ERROR"); |
58 const string16 kFailed = ASCIIToUTF16("FAILED"); | 57 const string16 kFailed = ASCIIToUTF16("FAILED"); |
59 GURL player_gurl = test_server()->GetURL(base::StringPrintf( | 58 GURL player_gurl = test_server()->GetURL(base::StringPrintf( |
60 "files/media/%s?keysystem=%s&mediafile=%s", html_page, key_system, | 59 "files/media/%s?keysystem=%s&mediafile=%s", html_page, key_system, |
61 media_file)); | 60 media_file)); |
62 content::TitleWatcher title_watcher(shell()->web_contents(), expectation); | 61 TitleWatcher title_watcher(shell()->web_contents(), expectation); |
63 title_watcher.AlsoWaitForTitle(kError); | 62 title_watcher.AlsoWaitForTitle(kError); |
64 title_watcher.AlsoWaitForTitle(kFailed); | 63 title_watcher.AlsoWaitForTitle(kFailed); |
65 | 64 |
66 content::NavigateToURL(shell(), player_gurl); | 65 NavigateToURL(shell(), player_gurl); |
67 | 66 |
68 string16 final_title = title_watcher.WaitAndGetTitle(); | 67 string16 final_title = title_watcher.WaitAndGetTitle(); |
69 EXPECT_EQ(expectation, final_title); | 68 EXPECT_EQ(expectation, final_title); |
70 | 69 |
71 if (final_title == kFailed) { | 70 if (final_title == kFailed) { |
72 std::string fail_message; | 71 std::string fail_message; |
73 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractString( | 72 EXPECT_TRUE(ExecuteJavaScriptAndExtractString( |
74 shell()->web_contents()->GetRenderViewHost(), L"", | 73 shell()->web_contents()->GetRenderViewHost(), L"", |
75 L"window.domAutomationController.send(failMessage);", &fail_message)); | 74 L"window.domAutomationController.send(failMessage);", &fail_message)); |
76 LOG(INFO) << "Test failed: " << fail_message; | 75 LOG(INFO) << "Test failed: " << fail_message; |
77 } | 76 } |
78 } | 77 } |
79 | 78 |
80 protected: | 79 protected: |
81 // Registers any CDM plugins not registered by default. | 80 // Registers any CDM plugins not registered by default. |
82 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 81 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
83 command_line->AppendSwitch(switches::kDisableAudio); | 82 command_line->AppendSwitch(switches::kDisableAudio); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 122 } |
124 | 123 |
125 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, | 124 INSTANTIATE_TEST_CASE_P(ClearKey, EncryptedMediaTest, |
126 ::testing::Values(kClearKeyKeySystem)); | 125 ::testing::Values(kClearKeyKeySystem)); |
127 | 126 |
128 // http://crbug.com/152864 | 127 // http://crbug.com/152864 |
129 #if !defined(OS_MACOSX) | 128 #if !defined(OS_MACOSX) |
130 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, | 129 INSTANTIATE_TEST_CASE_P(ExternalClearKey, EncryptedMediaTest, |
131 ::testing::Values(kExternalClearKeyKeySystem)); | 130 ::testing::Values(kExternalClearKeyKeySystem)); |
132 #endif | 131 #endif |
| 132 |
| 133 } // namespace content |
OLD | NEW |