| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 16 #include "chrome/browser/infobars/infobar.h" |
| 17 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 15 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
| 22 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/test/base/test_launcher_utils.h" | 25 #include "chrome/test/base/test_launcher_utils.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/browser/dom_operation_notification_details.h" | 27 #include "content/public/browser/dom_operation_notification_details.h" |
| 22 #include "content/public/test/test_renderer_host.h" | 28 #include "content/public/test/test_renderer_host.h" |
| 29 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/common/content_paths.h" | 32 #include "content/public/common/content_paths.h" |
| 26 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 27 #include "content/public/test/browser_test_utils.h" | 34 #include "content/public/test/browser_test_utils.h" |
| 28 #include "content/test/gpu/test_switches.h" | 35 #include "content/test/gpu/test_switches.h" |
| 29 #include "media/audio/audio_manager.h" | 36 #include "media/audio/audio_manager.h" |
| 30 #include "net/base/net_util.h" | 37 #include "net/base/net_util.h" |
| 31 #include "net/test/test_server.h" | 38 #include "net/test/test_server.h" |
| 32 #include "ui/gl/gl_switches.h" | 39 #include "ui/gl/gl_switches.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 107 } |
| 101 } | 108 } |
| 102 | 109 |
| 103 void PPAPITestBase::TestFinishObserver::Reset() { | 110 void PPAPITestBase::TestFinishObserver::Reset() { |
| 104 finished_ = false; | 111 finished_ = false; |
| 105 waiting_ = false; | 112 waiting_ = false; |
| 106 result_.clear(); | 113 result_.clear(); |
| 107 } | 114 } |
| 108 | 115 |
| 109 void PPAPITestBase::TestFinishObserver::OnTimeout() { | 116 void PPAPITestBase::TestFinishObserver::OnTimeout() { |
| 110 MessageLoopForUI::current()->Quit(); | 117 // MessageLoopForUI::current()->Quit(); |
| 118 } |
| 119 |
| 120 PPAPITestBase::InfoBarObserver::InfoBarObserver() { |
| 121 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
| 122 content::NotificationService::AllSources()); |
| 123 } |
| 124 |
| 125 PPAPITestBase::InfoBarObserver::~InfoBarObserver() {} |
| 126 |
| 127 void PPAPITestBase::InfoBarObserver::Observe( |
| 128 int type, |
| 129 const content::NotificationSource& source, |
| 130 const content::NotificationDetails& details) { |
| 131 ASSERT_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, type); |
| 132 InfoBarDelegate* info_bar_delegate = |
| 133 content::Details<InfoBarAddedDetails>(details).ptr(); |
| 134 ConfirmInfoBarDelegate* confirm_info_bar_delegate = |
| 135 info_bar_delegate->AsConfirmInfoBarDelegate(); |
| 136 ASSERT_TRUE(confirm_info_bar_delegate); |
| 137 if (ShouldAcceptInfoBar(confirm_info_bar_delegate)) |
| 138 confirm_info_bar_delegate->Accept(); |
| 139 else |
| 140 confirm_info_bar_delegate->Cancel(); |
| 141 |
| 142 // TODO(bauerb): We should close the infobar. |
| 111 } | 143 } |
| 112 | 144 |
| 113 PPAPITestBase::PPAPITestBase() { | 145 PPAPITestBase::PPAPITestBase() { |
| 114 } | 146 } |
| 115 | 147 |
| 116 void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) { | 148 void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) { |
| 117 // Do not use mesa if real GPU is required. | 149 // Do not use mesa if real GPU is required. |
| 118 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { | 150 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { |
| 119 #if !defined(OS_MACOSX) | 151 #if !defined(OS_MACOSX) |
| 120 CHECK(test_launcher_utils::OverrideGLImplementation( | 152 CHECK(test_launcher_utils::OverrideGLImplementation( |
| 121 command_line, gfx::kGLImplementationOSMesaName)) << | 153 command_line, gfx::kGLImplementationOSMesaName)) << |
| 122 "kUseGL must not be set by test framework code!"; | 154 "kUseGL must not be set by test framework code!"; |
| 123 #endif | 155 #endif |
| 124 } | 156 } |
| 125 | 157 |
| 126 // The test sends us the result via a cookie. | 158 // The test sends us the result via a cookie. |
| 127 command_line->AppendSwitch(switches::kEnableFileCookies); | 159 command_line->AppendSwitch(switches::kEnableFileCookies); |
| 128 | 160 |
| 129 // Some stuff is hung off of the testing interface which is not enabled | 161 // Some stuff is hung off of the testing interface which is not enabled |
| 130 // by default. | 162 // by default. |
| 131 command_line->AppendSwitch(switches::kEnablePepperTesting); | 163 command_line->AppendSwitch(switches::kEnablePepperTesting); |
| 132 | 164 |
| 133 // Smooth scrolling confuses the scrollbar test. | 165 // Smooth scrolling confuses the scrollbar test. |
| 134 command_line->AppendSwitch(switches::kDisableSmoothScrolling); | 166 command_line->AppendSwitch(switches::kDisableSmoothScrolling); |
| 135 } | 167 } |
| 136 | 168 |
| 169 void PPAPITestBase::SetUpOnMainThread() { |
| 170 // Always allow access to the PPAPI broker. |
| 171 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( |
| 172 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW); |
| 173 } |
| 174 |
| 137 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) { | 175 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) { |
| 138 FilePath test_path; | 176 FilePath test_path; |
| 139 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path)); | 177 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path)); |
| 140 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi")); | 178 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi")); |
| 141 test_path = test_path.Append(FILE_PATH_LITERAL("tests")); | 179 test_path = test_path.Append(FILE_PATH_LITERAL("tests")); |
| 142 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html")); | 180 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html")); |
| 143 | 181 |
| 144 // Sanity check the file name. | 182 // Sanity check the file name. |
| 145 EXPECT_TRUE(file_util::PathExists(test_path)); | 183 EXPECT_TRUE(file_util::PathExists(test_path)); |
| 146 | 184 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 408 } |
| 371 | 409 |
| 372 // Append the correct mode and testcase string | 410 // Append the correct mode and testcase string |
| 373 std::string PPAPINaClTestDisallowedSockets::BuildQuery( | 411 std::string PPAPINaClTestDisallowedSockets::BuildQuery( |
| 374 const std::string& base, | 412 const std::string& base, |
| 375 const std::string& test_case) { | 413 const std::string& test_case) { |
| 376 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), | 414 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), |
| 377 test_case.c_str()); | 415 test_case.c_str()); |
| 378 } | 416 } |
| 379 | 417 |
| 418 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() { |
| 419 // The default content setting for the PPAPI broker is ASK. We purposefully |
| 420 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way. |
| 421 } |
| OLD | NEW |