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

Side by Side Diff: ppapi/tests/test_broker.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 | « ppapi/tests/test_broker.h ('k') | ppapi/tests/testing_instance.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 "ppapi/tests/test_broker.h" 5 #include "ppapi/tests/test_broker.h"
6 6
7 #if defined(_MSC_VER) 7 #if defined(_MSC_VER)
8 #define OS_WIN 1 8 #define OS_WIN 1
9 #include <windows.h> 9 #include <windows.h>
10 #else 10 #else
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 pp::Module::Get()->GetBrowserInterface(PPB_BROKER_TRUSTED_INTERFACE)); 207 pp::Module::Get()->GetBrowserInterface(PPB_BROKER_TRUSTED_INTERFACE));
208 return !!broker_interface_; 208 return !!broker_interface_;
209 } 209 }
210 210
211 void TestBroker::RunTests(const std::string& filter) { 211 void TestBroker::RunTests(const std::string& filter) {
212 RUN_TEST(Create, filter); 212 RUN_TEST(Create, filter);
213 RUN_TEST(Create, filter); 213 RUN_TEST(Create, filter);
214 RUN_TEST(GetHandleFailure, filter); 214 RUN_TEST(GetHandleFailure, filter);
215 RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter); 215 RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter);
216 RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter); 216 RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter);
217
218 // The following tests require special setup, so only run them if they're
219 // explicitly specified by the filter.
220 if (filter.empty())
221 return;
222
223 RUN_TEST(ConnectPermissionDenied, filter);
224 RUN_TEST(ConnectPermissionGranted, filter);
217 } 225 }
218 226
219 std::string TestBroker::TestCreate() { 227 std::string TestBroker::TestCreate() {
220 // Very simplistic test to make sure we can create a broker interface. 228 // Very simplistic test to make sure we can create a broker interface.
221 PP_Resource broker = broker_interface_->CreateTrusted( 229 PP_Resource broker = broker_interface_->CreateTrusted(
222 instance_->pp_instance()); 230 instance_->pp_instance());
223 ASSERT_TRUE(broker); 231 ASSERT_TRUE(broker);
224 232
225 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0)); 233 ASSERT_FALSE(broker_interface_->IsBrokerTrusted(0));
226 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker)); 234 ASSERT_TRUE(broker_interface_->IsBrokerTrusted(broker));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 279
272 PlatformFile file = IntToPlatformFile(handle); 280 PlatformFile file = IntToPlatformFile(handle);
273 ASSERT_TRUE(VerifyMessage(file, sizeof(kHelloMessage), kHelloMessage)); 281 ASSERT_TRUE(VerifyMessage(file, sizeof(kHelloMessage), kHelloMessage));
274 ASSERT_TRUE(VerifyMessage(file, sizeof(kBrokerUnsandboxed), 282 ASSERT_TRUE(VerifyMessage(file, sizeof(kBrokerUnsandboxed),
275 kBrokerUnsandboxed)); 283 kBrokerUnsandboxed));
276 284
277 ASSERT_TRUE(ClosePlatformFile(file)); 285 ASSERT_TRUE(ClosePlatformFile(file));
278 286
279 PASS(); 287 PASS();
280 } 288 }
289
290 std::string TestBroker::TestConnectPermissionDenied() {
291 // This assumes that the browser side is set up to deny access to the broker.
292 PP_Resource broker = broker_interface_->CreateTrusted(
293 instance_->pp_instance());
294 ASSERT_TRUE(broker);
295
296 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
297 callback.WaitForResult(broker_interface_->Connect(broker,
298 callback.GetCallback().pp_completion_callback()));
299 CHECK_CALLBACK_BEHAVIOR(callback);
300 ASSERT_EQ(PP_ERROR_NOACCESS, callback.result());
301
302 PASS();
303 }
304
305 std::string TestBroker::TestConnectPermissionGranted() {
306 // This assumes that the browser side is set up to allow access to the broker.
307 PP_Resource broker = broker_interface_->CreateTrusted(
308 instance_->pp_instance());
309 ASSERT_TRUE(broker);
310
311 TestCompletionCallback callback(instance_->pp_instance(), callback_type());
312 callback.WaitForResult(broker_interface_->Connect(broker,
313 callback.GetCallback().pp_completion_callback()));
314 CHECK_CALLBACK_BEHAVIOR(callback);
315 ASSERT_EQ(PP_OK, callback.result());
316
317 PASS();
318 }
319
OLDNEW
« no previous file with comments | « ppapi/tests/test_broker.h ('k') | ppapi/tests/testing_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698