| OLD | NEW |
| 1 // Copyright 2008-2009, Google Inc. | 1 // Copyright 2008-2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include <atlbase.h> | 43 #include <atlbase.h> |
| 44 #include <comutil.h> | 44 #include <comutil.h> |
| 45 | 45 |
| 46 #include <stdlib.h> | 46 #include <stdlib.h> |
| 47 #include <string.h> | 47 #include <string.h> |
| 48 #include <memory.h> | 48 #include <memory.h> |
| 49 | 49 |
| 50 #include "base/file_path.h" | 50 #include "base/file_path.h" |
| 51 #include "base/file_util.h" | 51 #include "base/file_util.h" |
| 52 #include "base/registry.h" | 52 #include "base/registry.h" |
| 53 #include "chrome/browser/net/url_request_mock_http_job.h" |
| 53 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 54 #include "chrome/common/chrome_paths.h" | 55 #include "chrome/common/chrome_paths.h" |
| 55 #include "chrome/test/automation/tab_proxy.h" | 56 #include "chrome/test/automation/tab_proxy.h" |
| 56 #include "chrome/test/ui/ui_test.h" | 57 #include "chrome/test/ui/ui_test.h" |
| 57 #include "net/base/net_util.h" | 58 #include "net/base/net_util.h" |
| 58 #include "third_party/npapi/bindings/npapi.h" | 59 #include "third_party/npapi/bindings/npapi.h" |
| 59 #include "webkit/default_plugin/plugin_impl.h" | 60 #include "webkit/default_plugin/plugin_impl.h" |
| 60 #include "webkit/glue/plugins/plugin_constants_win.h" | 61 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 61 #include "webkit/glue/plugins/plugin_list.h" | 62 #include "webkit/glue/plugins/plugin_list.h" |
| 62 | 63 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 87 launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch); | 88 launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch); |
| 88 launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch); | 89 launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch); |
| 89 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { | 90 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { |
| 90 launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, | 91 launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, |
| 91 L"security_tests.dll"); | 92 L"security_tests.dll"); |
| 92 } | 93 } |
| 93 | 94 |
| 94 UITest::SetUp(); | 95 UITest::SetUp(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void TestPlugin(const std::wstring& test_case, int timeout) { | 98 void TestPlugin(const std::wstring& test_case, |
| 98 GURL url = GetTestUrl(test_case); | 99 int timeout, |
| 100 bool mock_http) { |
| 101 GURL url = GetTestUrl(test_case, mock_http); |
| 99 NavigateToURL(url); | 102 NavigateToURL(url); |
| 100 WaitForFinish(timeout); | 103 WaitForFinish(timeout, mock_http); |
| 101 } | 104 } |
| 102 | 105 |
| 103 // Generate the URL for testing a particular test. | 106 // Generate the URL for testing a particular test. |
| 104 // HTML for the tests is all located in test_directory\plugin\<testcase> | 107 // HTML for the tests is all located in test_directory\plugin\<testcase> |
| 105 GURL GetTestUrl(const std::wstring &test_case) { | 108 // Set |mock_http| to true to use mock HTTP server. |
| 109 GURL GetTestUrl(const std::wstring &test_case, bool mock_http) { |
| 110 if (mock_http) |
| 111 return URLRequestMockHTTPJob::GetMockUrl(L"plugin/" + test_case); |
| 112 |
| 106 FilePath path; | 113 FilePath path; |
| 107 PathService::Get(chrome::DIR_TEST_DATA, &path); | 114 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 108 path = path.AppendASCII("plugin"); | 115 path = path.AppendASCII("plugin"); |
| 109 path = path.Append(FilePath::FromWStringHack(test_case)); | 116 path = path.Append(FilePath::FromWStringHack(test_case)); |
| 110 return net::FilePathToFileURL(path); | 117 return net::FilePathToFileURL(path); |
| 111 } | 118 } |
| 112 | 119 |
| 113 // Waits for the test case to finish. | 120 // Waits for the test case to finish. |
| 114 void WaitForFinish(const int wait_time) { | 121 void WaitForFinish(const int wait_time, bool mock_http) { |
| 115 const int kSleepTime = 500; // 2 times per second | 122 const int kSleepTime = 500; // 2 times per second |
| 116 const int kMaxIntervals = wait_time / kSleepTime; | 123 const int kMaxIntervals = wait_time / kSleepTime; |
| 117 | 124 |
| 118 GURL url = GetTestUrl(L"done"); | 125 GURL url = GetTestUrl(L"done", mock_http); |
| 119 scoped_refptr<TabProxy> tab(GetActiveTab()); | 126 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 120 | 127 |
| 121 std::string done_str; | 128 std::string done_str; |
| 122 for (int i = 0; i < kMaxIntervals; ++i) { | 129 for (int i = 0; i < kMaxIntervals; ++i) { |
| 123 Sleep(kSleepTime); | 130 Sleep(kSleepTime); |
| 124 | 131 |
| 125 // The webpage being tested has javascript which sets a cookie | 132 // The webpage being tested has javascript which sets a cookie |
| 126 // which signals completion of the test. | 133 // which signals completion of the test. |
| 127 std::string cookieName = kTestCompleteCookie; | 134 std::string cookieName = kTestCompleteCookie; |
| 128 tab->GetCookieByName(url, cookieName, &done_str); | 135 tab->GetCookieByName(url, cookieName, &done_str); |
| 129 if (!done_str.empty()) | 136 if (!done_str.empty()) |
| 130 break; | 137 break; |
| 131 } | 138 } |
| 132 | 139 |
| 133 EXPECT_EQ(kTestCompleteSuccess, done_str); | 140 EXPECT_EQ(kTestCompleteSuccess, done_str); |
| 134 } | 141 } |
| 135 }; | 142 }; |
| 136 | 143 |
| 137 TEST_F(PluginTest, Quicktime) { | 144 TEST_F(PluginTest, Quicktime) { |
| 138 TestPlugin(L"quicktime.html", kShortWaitTimeout); | 145 TestPlugin(L"quicktime.html", kShortWaitTimeout, false); |
| 139 } | 146 } |
| 140 | 147 |
| 141 TEST_F(PluginTest, DISABLED_MediaPlayerNew) { | 148 TEST_F(PluginTest, DISABLED_MediaPlayerNew) { |
| 142 TestPlugin(L"wmp_new.html", kShortWaitTimeout); | 149 TestPlugin(L"wmp_new.html", kShortWaitTimeout, false); |
| 143 } | 150 } |
| 144 | 151 |
| 145 // http://crbug.com/4809 | 152 // http://crbug.com/4809 |
| 146 TEST_F(PluginTest, DISABLED_MediaPlayerOld) { | 153 TEST_F(PluginTest, DISABLED_MediaPlayerOld) { |
| 147 TestPlugin(L"wmp_old.html", kLongWaitTimeout); | 154 TestPlugin(L"wmp_old.html", kLongWaitTimeout, false); |
| 148 } | 155 } |
| 149 | 156 |
| 150 TEST_F(PluginTest, Real) { | 157 TEST_F(PluginTest, Real) { |
| 151 TestPlugin(L"real.html", kShortWaitTimeout); | 158 TestPlugin(L"real.html", kShortWaitTimeout, false); |
| 152 } | 159 } |
| 153 | 160 |
| 154 TEST_F(PluginTest, Flash) { | 161 TEST_F(PluginTest, Flash) { |
| 155 TestPlugin(L"flash.html", kShortWaitTimeout); | 162 TestPlugin(L"flash.html", kShortWaitTimeout, false); |
| 156 } | 163 } |
| 157 | 164 |
| 158 TEST_F(PluginTest, FlashOctetStream) { | 165 TEST_F(PluginTest, FlashOctetStream) { |
| 159 TestPlugin(L"flash-octet-stream.html", kShortWaitTimeout); | 166 TestPlugin(L"flash-octet-stream.html", kShortWaitTimeout, false); |
| 160 } | 167 } |
| 161 | 168 |
| 162 TEST_F(PluginTest, FlashSecurity) { | 169 TEST_F(PluginTest, FlashSecurity) { |
| 163 TestPlugin(L"flash.html", kShortWaitTimeout); | 170 TestPlugin(L"flash.html", kShortWaitTimeout, false); |
| 171 } |
| 172 |
| 173 // http://crbug.com/16114 |
| 174 TEST_F(PluginTest, FlashLayoutWhilePainting) { |
| 175 TestPlugin(L"flash-layout-while-painting.html", kShortWaitTimeout, true); |
| 164 } | 176 } |
| 165 | 177 |
| 166 // http://crbug.com/8690 | 178 // http://crbug.com/8690 |
| 167 TEST_F(PluginTest, DISABLED_Java) { | 179 TEST_F(PluginTest, DISABLED_Java) { |
| 168 TestPlugin(L"Java.html", kShortWaitTimeout); | 180 TestPlugin(L"Java.html", kShortWaitTimeout, false); |
| 169 } | 181 } |
| 170 | 182 |
| 171 TEST_F(PluginTest, Silverlight) { | 183 TEST_F(PluginTest, Silverlight) { |
| 172 TestPlugin(L"silverlight.html", kShortWaitTimeout); | 184 TestPlugin(L"silverlight.html", kShortWaitTimeout, false); |
| 173 } | 185 } |
| 174 | 186 |
| 175 typedef HRESULT (__stdcall* DllRegUnregServerFunc)(); | 187 typedef HRESULT (__stdcall* DllRegUnregServerFunc)(); |
| 176 | 188 |
| 177 class ActiveXTest : public PluginTest { | 189 class ActiveXTest : public PluginTest { |
| 178 public: | 190 public: |
| 179 ActiveXTest() { | 191 ActiveXTest() { |
| 180 dll_registered = false; | 192 dll_registered = false; |
| 181 } | 193 } |
| 182 protected: | 194 protected: |
| 183 void TestActiveX(const std::wstring& test_case, int timeout, bool reg_dll) { | 195 void TestActiveX(const std::wstring& test_case, int timeout, bool reg_dll) { |
| 184 if (reg_dll) { | 196 if (reg_dll) { |
| 185 RegisterTestControl(true); | 197 RegisterTestControl(true); |
| 186 dll_registered = true; | 198 dll_registered = true; |
| 187 } | 199 } |
| 188 TestPlugin(test_case, timeout); | 200 TestPlugin(test_case, timeout, false); |
| 189 } | 201 } |
| 190 virtual void TearDown() { | 202 virtual void TearDown() { |
| 191 PluginTest::TearDown(); | 203 PluginTest::TearDown(); |
| 192 if (dll_registered) | 204 if (dll_registered) |
| 193 RegisterTestControl(false); | 205 RegisterTestControl(false); |
| 194 } | 206 } |
| 195 void RegisterTestControl(bool register_server) { | 207 void RegisterTestControl(bool register_server) { |
| 196 std::wstring test_control_path = browser_directory_.ToWStringHack() + | 208 std::wstring test_control_path = browser_directory_.ToWStringHack() + |
| 197 L"\\activex_test_control.dll"; | 209 L"\\activex_test_control.dll"; |
| 198 HMODULE h = LoadLibrary(test_control_path.c_str()); | 210 HMODULE h = LoadLibrary(test_control_path.c_str()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 activex_codebase, | 324 activex_codebase, |
| 313 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); | 325 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); |
| 314 | 326 |
| 315 EXPECT_EQ(activex_clsid, "{D27CDB6E-AE6D-11cf-96B8-444553540000}"); | 327 EXPECT_EQ(activex_clsid, "{D27CDB6E-AE6D-11cf-96B8-444553540000}"); |
| 316 EXPECT_EQ(raw_activex_clsid, "D27CDB6E-AE6D-11cf-96B8-444553540000"); | 328 EXPECT_EQ(raw_activex_clsid, "D27CDB6E-AE6D-11cf-96B8-444553540000"); |
| 317 | 329 |
| 318 EXPECT_EQ( | 330 EXPECT_EQ( |
| 319 activex_codebase, | 331 activex_codebase, |
| 320 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); | 332 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); |
| 321 } | 333 } |
| OLD | NEW |