Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/test/ppapi/ppapi_test.cc

Issue 10826164: Add infobar for PPAPI broker usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/ppapi/ppapi_test.h ('k') | ppapi/tests/test_broker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/api/infobars/confirm_infobar_delegate.h"
16 #include "chrome/browser/content_settings/host_content_settings_map.h"
17 #include "chrome/browser/infobars/infobar.h"
18 #include "chrome/browser/infobars/infobar_tab_helper.h"
19 #include "chrome/browser/profiles/profile.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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 message_ = trimmed; 73 message_ = trimmed;
67 return DONE; 74 return DONE;
68 } 75 }
69 } 76 }
70 77
71 void PPAPITestMessageHandler::Reset() { 78 void PPAPITestMessageHandler::Reset() {
72 TestMessageHandler::Reset(); 79 TestMessageHandler::Reset();
73 message_.clear(); 80 message_.clear();
74 } 81 }
75 82
83 PPAPITestBase::InfoBarObserver::InfoBarObserver() {
84 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
85 content::NotificationService::AllSources());
86 }
87
88 PPAPITestBase::InfoBarObserver::~InfoBarObserver() {
89 EXPECT_EQ(0u, expected_infobars_.size()) << "Missing an expected infobar";
90 }
91
92 void PPAPITestBase::InfoBarObserver::Observe(
93 int type,
94 const content::NotificationSource& source,
95 const content::NotificationDetails& details) {
96 ASSERT_EQ(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, type);
97 InfoBarDelegate* info_bar_delegate =
98 content::Details<InfoBarAddedDetails>(details).ptr();
99 ConfirmInfoBarDelegate* confirm_info_bar_delegate =
100 info_bar_delegate->AsConfirmInfoBarDelegate();
101 ASSERT_TRUE(confirm_info_bar_delegate);
102
103 ASSERT_FALSE(expected_infobars_.empty()) << "Unexpected infobar";
104 if (expected_infobars_.front())
105 confirm_info_bar_delegate->Accept();
106 else
107 confirm_info_bar_delegate->Cancel();
108 expected_infobars_.pop_front();
109
110 // TODO(bauerb): We should close the infobar.
111 }
112
113 void PPAPITestBase::InfoBarObserver::ExpectInfoBarAndAccept(
114 bool should_accept) {
115 expected_infobars_.push_back(should_accept);
116 }
117
76 PPAPITestBase::PPAPITestBase() { 118 PPAPITestBase::PPAPITestBase() {
77 } 119 }
78 120
79 void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) { 121 void PPAPITestBase::SetUpCommandLine(CommandLine* command_line) {
80 // Do not use mesa if real GPU is required. 122 // Do not use mesa if real GPU is required.
81 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { 123 if (!command_line->HasSwitch(switches::kUseGpuInTests)) {
82 #if !defined(OS_MACOSX) 124 #if !defined(OS_MACOSX)
83 CHECK(test_launcher_utils::OverrideGLImplementation( 125 CHECK(test_launcher_utils::OverrideGLImplementation(
84 command_line, gfx::kGLImplementationOSMesaName)) << 126 command_line, gfx::kGLImplementationOSMesaName)) <<
85 "kUseGL must not be set by test framework code!"; 127 "kUseGL must not be set by test framework code!";
86 #endif 128 #endif
87 } 129 }
88 130
89 // The test sends us the result via a cookie. 131 // The test sends us the result via a cookie.
90 command_line->AppendSwitch(switches::kEnableFileCookies); 132 command_line->AppendSwitch(switches::kEnableFileCookies);
91 133
92 // Some stuff is hung off of the testing interface which is not enabled 134 // Some stuff is hung off of the testing interface which is not enabled
93 // by default. 135 // by default.
94 command_line->AppendSwitch(switches::kEnablePepperTesting); 136 command_line->AppendSwitch(switches::kEnablePepperTesting);
95 137
96 // Smooth scrolling confuses the scrollbar test. 138 // Smooth scrolling confuses the scrollbar test.
97 command_line->AppendSwitch(switches::kDisableSmoothScrolling); 139 command_line->AppendSwitch(switches::kDisableSmoothScrolling);
98 } 140 }
99 141
142 void PPAPITestBase::SetUpOnMainThread() {
143 // Always allow access to the PPAPI broker.
144 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
145 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW);
146 }
147
100 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) { 148 GURL PPAPITestBase::GetTestFileUrl(const std::string& test_case) {
101 FilePath test_path; 149 FilePath test_path;
102 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path)); 150 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &test_path));
103 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi")); 151 test_path = test_path.Append(FILE_PATH_LITERAL("ppapi"));
104 test_path = test_path.Append(FILE_PATH_LITERAL("tests")); 152 test_path = test_path.Append(FILE_PATH_LITERAL("tests"));
105 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html")); 153 test_path = test_path.Append(FILE_PATH_LITERAL("test_case.html"));
106 154
107 // Sanity check the file name. 155 // Sanity check the file name.
108 EXPECT_TRUE(file_util::PathExists(test_path)); 156 EXPECT_TRUE(file_util::PathExists(test_path));
109 157
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 343 }
296 344
297 // Append the correct mode and testcase string 345 // Append the correct mode and testcase string
298 std::string PPAPINaClTestDisallowedSockets::BuildQuery( 346 std::string PPAPINaClTestDisallowedSockets::BuildQuery(
299 const std::string& base, 347 const std::string& base,
300 const std::string& test_case) { 348 const std::string& test_case) {
301 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), 349 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(),
302 test_case.c_str()); 350 test_case.c_str());
303 } 351 }
304 352
353 void PPAPIBrokerInfoBarTest::SetUpOnMainThread() {
354 // The default content setting for the PPAPI broker is ASK. We purposefully
355 // don't call PPAPITestBase::SetUpOnMainThread() to keep it that way.
356 }
OLDNEW
« no previous file with comments | « chrome/test/ppapi/ppapi_test.h ('k') | ppapi/tests/test_broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698