| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 133 |
| 129 // Disable tests under ASAN. http://crbug.com/104832. | 134 // Disable tests under ASAN. http://crbug.com/104832. |
| 130 // This is a bit heavy handed, but the majority of these tests fail under ASAN. | 135 // This is a bit heavy handed, but the majority of these tests fail under ASAN. |
| 131 // See bug for history. | 136 // See bug for history. |
| 132 #if !defined(ADDRESS_SANITIZER) | 137 #if !defined(ADDRESS_SANITIZER) |
| 133 | 138 |
| 134 TEST_PPAPI_IN_PROCESS(Broker) | 139 TEST_PPAPI_IN_PROCESS(Broker) |
| 135 // Flaky, http://crbug.com/111355 | 140 // Flaky, http://crbug.com/111355 |
| 136 TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker) | 141 TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker) |
| 137 | 142 |
| 143 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Accept) { |
| 144 // Accepting the infobar should grant permission to access the PPAPI broker. |
| 145 StrictMock<InfoBarObserver> observer; |
| 146 EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(true)); |
| 147 |
| 148 GURL url = GetTestFileUrl("Broker_ConnectPermissionGranted"); |
| 149 RunTestURL(url); |
| 150 |
| 151 // It should also set a content settings exception for the site. |
| 152 HostContentSettingsMap* content_settings = |
| 153 browser()->profile()->GetHostContentSettingsMap(); |
| 154 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 155 content_settings->GetContentSetting( |
| 156 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); |
| 157 } |
| 158 |
| 159 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Deny) { |
| 160 // Canceling the infobar should deny permission to access the PPAPI broker. |
| 161 StrictMock<InfoBarObserver> observer; |
| 162 EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(false)); |
| 163 |
| 164 GURL url = GetTestFileUrl("Broker_ConnectPermissionDenied"); |
| 165 RunTestURL(url); |
| 166 |
| 167 // It should *not* set a content settings exception for the site. |
| 168 HostContentSettingsMap* content_settings = |
| 169 browser()->profile()->GetHostContentSettingsMap(); |
| 170 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 171 content_settings->GetContentSetting( |
| 172 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); |
| 173 } |
| 174 |
| 175 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Blocked) { |
| 176 // Block access to the PPAPI broker. |
| 177 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 178 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_BLOCK); |
| 179 |
| 180 // We shouldn't see an infobar. |
| 181 StrictMock<InfoBarObserver> observer; |
| 182 |
| 183 RunTest("Broker_ConnectPermissionDenied"); |
| 184 } |
| 185 |
| 186 IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Allowed) { |
| 187 // Always allow access to the PPAPI broker. |
| 188 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 189 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW); |
| 190 |
| 191 // We shouldn't see an infobar. |
| 192 StrictMock<InfoBarObserver> observer; |
| 193 |
| 194 RunTest("Broker_ConnectPermissionGranted"); |
| 195 } |
| 196 |
| 138 TEST_PPAPI_IN_PROCESS(Core) | 197 TEST_PPAPI_IN_PROCESS(Core) |
| 139 TEST_PPAPI_OUT_OF_PROCESS(Core) | 198 TEST_PPAPI_OUT_OF_PROCESS(Core) |
| 140 TEST_PPAPI_NACL_VIA_HTTP(Core) | 199 TEST_PPAPI_NACL_VIA_HTTP(Core) |
| 141 | 200 |
| 142 // Times out on Linux. http://crbug.com/108859 | 201 // Times out on Linux. http://crbug.com/108859 |
| 143 #if defined(OS_LINUX) | 202 #if defined(OS_LINUX) |
| 144 #define MAYBE_InputEvent DISABLED_InputEvent | 203 #define MAYBE_InputEvent DISABLED_InputEvent |
| 145 #elif defined(OS_MACOSX) | 204 #elif defined(OS_MACOSX) |
| 146 // Flaky on Mac. http://crbug.com/109258 | 205 // Flaky on Mac. http://crbug.com/109258 |
| 147 #define MAYBE_InputEvent DISABLED_InputEvent | 206 #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) | 861 TEST_PPAPI_OUT_OF_PROCESS(FlashMessageLoop_RunWithoutQuit) |
| 803 | 862 |
| 804 TEST_PPAPI_IN_PROCESS(MouseCursor) | 863 TEST_PPAPI_IN_PROCESS(MouseCursor) |
| 805 TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) | 864 TEST_PPAPI_OUT_OF_PROCESS(MouseCursor) |
| 806 TEST_PPAPI_NACL_VIA_HTTP(MouseCursor) | 865 TEST_PPAPI_NACL_VIA_HTTP(MouseCursor) |
| 807 | 866 |
| 808 // Only enabled in out-of-process mode. | 867 // Only enabled in out-of-process mode. |
| 809 TEST_PPAPI_OUT_OF_PROCESS(FlashFile_CreateTemporaryFile) | 868 TEST_PPAPI_OUT_OF_PROCESS(FlashFile_CreateTemporaryFile) |
| 810 | 869 |
| 811 #endif // ADDRESS_SANITIZER | 870 #endif // ADDRESS_SANITIZER |
| OLD | NEW |