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

Side by Side Diff: ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.cc

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "native_client/src/shared/platform/nacl_check.h"
6 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
7 #include "native_client/tests/ppapi_test_lib/test_interface.h"
8
9 #include "ppapi/c/pp_size.h"
10 #include "ppapi/c/ppb_image_data.h"
11 #include "ppapi/c/ppb_instance.h"
12 #include "ppapi/c/ppb_graphics_2d.h"
13
14 namespace {
15
16
17 // Tests PPB_Instance::IsFullFrame().
18 void TestIsFullFrame() {
19 // Note: IsFullFrame returning PP_TRUE is only possible when a plugin
20 // is a content handler. For coverage, see:
21 // tests/ppapi_browser/extension_mime_handler/
22 PP_Bool full_frame = PPBInstance()->IsFullFrame(pp_instance());
23 EXPECT(full_frame == PP_FALSE);
24
25 full_frame = PPBInstance()->IsFullFrame(kInvalidInstance);
26 EXPECT(full_frame == PP_FALSE);
27
28 TEST_PASSED;
29 }
30
31 void TestBindGraphics() {
32 PP_Size size = PP_MakeSize(100, 100);
33
34 PP_Resource graphics1 = PPBGraphics2D()->Create(
35 pp_instance(), &size, PP_TRUE);
36 PP_Resource graphics2 = PPBGraphics2D()->Create(
37 pp_instance(), &size, PP_TRUE);
38
39 EXPECT(graphics1 != kInvalidResource);
40 EXPECT(graphics2 != kInvalidResource);
41
42 PP_Bool ret = PPBInstance()->BindGraphics(pp_instance(), graphics1);
43 EXPECT(ret == PP_TRUE);
44
45 // We should be allowed to replace one device with another.
46 ret = PPBInstance()->BindGraphics(pp_instance(), graphics2);
47 EXPECT(ret == PP_TRUE);
48
49 // This should fail because instance is not valid.
50 ret = PPBInstance()->BindGraphics(kInvalidInstance, graphics1);
51 EXPECT(ret == PP_FALSE);
52
53 // This should fail because instance is not valid and graphics2 is bound.
54 ret = PPBInstance()->BindGraphics(kInvalidInstance, graphics2);
55 EXPECT(ret == PP_FALSE);
56
57 // This is not a failure, binding resource 0 simply unbinds all devices.
58 ret = PPBInstance()->BindGraphics(pp_instance(), kInvalidResource);
59 EXPECT(ret == PP_TRUE);
60
61 PP_Resource image_data = PPBImageData()->Create(
62 pp_instance(), PP_IMAGEDATAFORMAT_RGBA_PREMUL, &size, PP_FALSE);
63 EXPECT(image_data != kInvalidResource);
64
65 // This should fail because the resource is the wrong type.
66 ret = PPBInstance()->BindGraphics(pp_instance(), image_data);
67 EXPECT(ret == PP_FALSE);
68
69 TEST_PASSED;
70 }
71
72 } // namespace
73
74 void SetupTests() {
75 RegisterTest("TestIsFullFrame", TestIsFullFrame);
76 RegisterTest("TestBindGraphics", TestBindGraphics);
77 }
78
79 void SetupPluginInterfaces() {
80 // none
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698