Chromium Code Reviews| 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 "chrome/test/ppapi/ppapi_test.h" | 5 #include "chrome/test/ppapi/ppapi_test.h" |
| 6 | 6 |
| 7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" | 12 #include "chrome/browser/ui/browser_navigator.h" |
| 11 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/test/test_renderer_host.h" | 17 #include "content/public/test/test_renderer_host.h" |
| 16 | 18 |
| 17 using content::RenderViewHost; | 19 using content::RenderViewHost; |
| 20 using ::testing::Return; | |
| 21 using ::testing::StrictMock; | |
| 22 using ::testing::_; | |
| 18 | 23 |
| 19 // This macro finesses macro expansion to do what we want. | 24 // This macro finesses macro expansion to do what we want. |
| 20 #define STRIP_PREFIXES(test_name) StripPrefixes(#test_name) | 25 #define STRIP_PREFIXES(test_name) StripPrefixes(#test_name) |
| 21 | 26 |
| 22 // Use these macros to run the tests for a specific interface. | 27 // Use these macros to run the tests for a specific interface. |
| 23 // Most interfaces should be tested with both macros. | 28 // Most interfaces should be tested with both macros. |
| 24 #define TEST_PPAPI_IN_PROCESS(test_name) \ | 29 #define TEST_PPAPI_IN_PROCESS(test_name) \ |
| 25 IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \ | 30 IN_PROC_BROWSER_TEST_F(PPAPITest, test_name) { \ |
| 26 RunTest(STRIP_PREFIXES(test_name)); \ | 31 RunTest(STRIP_PREFIXES(test_name)); \ |
| 27 } | 32 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 | 118 |
| 114 // NaCl based PPAPI tests requiring an Audio device. | 119 // NaCl based PPAPI tests requiring an Audio device. |
| 115 #define TEST_PPAPI_NACL_VIA_HTTP_WITH_AUDIO_OUTPUT(test_name) \ | 120 #define TEST_PPAPI_NACL_VIA_HTTP_WITH_AUDIO_OUTPUT(test_name) \ |
| 116 IN_PROC_BROWSER_TEST_F(PPAPINaClNewlibTest, test_name) { \ | 121 IN_PROC_BROWSER_TEST_F(PPAPINaClNewlibTest, test_name) { \ |
| 117 RunTestViaHTTPIfAudioOutputAvailable(STRIP_PREFIXES(test_name)); \ | 122 RunTestViaHTTPIfAudioOutputAvailable(STRIP_PREFIXES(test_name)); \ |
| 118 } \ | 123 } \ |
| 119 IN_PROC_BROWSER_TEST_F(PPAPINaClGLibcTest, test_name) { \ | 124 IN_PROC_BROWSER_TEST_F(PPAPINaClGLibcTest, test_name) { \ |
| 120 RunTestViaHTTPIfAudioOutputAvailable(STRIP_PREFIXES(test_name)); \ | 125 RunTestViaHTTPIfAudioOutputAvailable(STRIP_PREFIXES(test_name)); \ |
| 121 } | 126 } |
| 122 #endif | 127 #endif |
| 123 | 128 |
|
markusheintz_
2012/08/13 06:09:06
nit: pls remove empty line.
Bernhard Bauer
2012/08/13 10:51:46
Done.
| |
| 124 | 129 |
| 130 | |
| 125 // | 131 // |
| 126 // Interface tests. | 132 // Interface tests. |
| 127 // | 133 // |
| 128 | 134 |
| 129 // Disable tests under ASAN. http://crbug.com/104832. | 135 // Disable tests under ASAN. http://crbug.com/104832. |
| 130 // This is a bit heavy handed, but the majority of these tests fail under ASAN. | 136 // This is a bit heavy handed, but the majority of these tests fail under ASAN. |
| 131 // See bug for history. | 137 // See bug for history. |
| 132 #if !defined(ADDRESS_SANITIZER) | 138 #if !defined(ADDRESS_SANITIZER) |
| 133 | 139 |
| 134 TEST_PPAPI_IN_PROCESS(Broker) | 140 TEST_PPAPI_IN_PROCESS(Broker) |
| 135 // Flaky, http://crbug.com/111355 | 141 // Flaky, http://crbug.com/111355 |
| 136 TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker) | 142 TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker) |
| 137 | 143 |
| 144 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Accept) { | |
| 145 // Accepting the infobar should grant permission to access the PPAPI broker. | |
| 146 StrictMock<InfoBarObserver> observer; | |
| 147 EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(true)); | |
| 148 | |
| 149 GURL url = GetTestFileUrl("Broker_ConnectPermissionGranted"); | |
| 150 RunTestURL(url); | |
| 151 | |
| 152 // It should also set a content settings exception for the site. | |
| 153 HostContentSettingsMap* content_settings = | |
| 154 browser()->profile()->GetHostContentSettingsMap(); | |
| 155 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
| 156 content_settings->GetContentSetting( | |
| 157 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); | |
| 158 } | |
| 159 | |
| 160 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Deny) { | |
| 161 // Canceling the infobar should deny permission to access the PPAPI broker. | |
| 162 StrictMock<InfoBarObserver> observer; | |
| 163 EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(false)); | |
| 164 | |
| 165 GURL url = GetTestFileUrl("Broker_ConnectPermissionDenied"); | |
| 166 RunTestURL(url); | |
| 167 | |
| 168 // It should *not* set a content settings exception for the site. | |
| 169 HostContentSettingsMap* content_settings = | |
| 170 browser()->profile()->GetHostContentSettingsMap(); | |
| 171 EXPECT_EQ(CONTENT_SETTING_ASK, | |
| 172 content_settings->GetContentSetting( | |
| 173 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); | |
| 174 } | |
| 175 | |
| 176 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Blocked) { | |
| 177 // Block access to the PPAPI broker. | |
| 178 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | |
| 179 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_BLOCK); | |
| 180 | |
| 181 // We shouldn't see an infobar. | |
| 182 StrictMock<InfoBarObserver> observer; | |
| 183 | |
| 184 RunTest("Broker_ConnectPermissionDenied"); | |
| 185 } | |
| 186 | |
| 187 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Allowed) { | |
| 188 // Always allow access to the PPAPI broker. | |
| 189 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( | |
| 190 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW); | |
| 191 | |
| 192 // We shouldn't see an infobar. | |
| 193 StrictMock<InfoBarObserver> observer; | |
| 194 | |
| 195 RunTest("Broker_ConnectPermissionGranted"); | |
| 196 } | |
| 197 | |
| 138 TEST_PPAPI_IN_PROCESS(Core) | 198 TEST_PPAPI_IN_PROCESS(Core) |
| 139 TEST_PPAPI_OUT_OF_PROCESS(Core) | 199 TEST_PPAPI_OUT_OF_PROCESS(Core) |
| 140 TEST_PPAPI_NACL_VIA_HTTP(Core) | 200 TEST_PPAPI_NACL_VIA_HTTP(Core) |
| 141 | 201 |
| 142 // Times out on Linux. http://crbug.com/108859 | 202 // Times out on Linux. http://crbug.com/108859 |
| 143 #if defined(OS_LINUX) | 203 #if defined(OS_LINUX) |
| 144 #define MAYBE_InputEvent DISABLED_InputEvent | 204 #define MAYBE_InputEvent DISABLED_InputEvent |
| 145 #elif defined(OS_MACOSX) | 205 #elif defined(OS_MACOSX) |
| 146 // Flaky on Mac. http://crbug.com/109258 | 206 // Flaky on Mac. http://crbug.com/109258 |
| 147 #define MAYBE_InputEvent DISABLED_InputEvent | 207 #define MAYBE_InputEvent DISABLED_InputEvent |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) | 862 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) |
| 803 | 863 |
| 804 TEST_PPAPI_IN_PROCESS(MouseCursor) | 864 TEST_PPAPI_IN_PROCESS(MouseCursor) |
| 805 TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) | 865 TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) |
| 806 TEST_PPAPI_NACL_VIA_HTTP(MouseCursor) | 866 TEST_PPAPI_NACL_VIA_HTTP(MouseCursor) |
| 807 | 867 |
| 808 // Only enabled in out-of-process mode. | 868 // Only enabled in out-of-process mode. |
| 809 TEST_PPAPI_OUT_OF_PROCESS(FlashFile_CreateTemporaryFile) | 869 TEST_PPAPI_OUT_OF_PROCESS(FlashFile_CreateTemporaryFile) |
| 810 | 870 |
| 811 #endif // ADDRESS_SANITIZER | 871 #endif // ADDRESS_SANITIZER |
| OLD | NEW |