1 // Copyright 2013 The Chromium 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.
5 #include "native_client/src/shared/platform/nacl_check.h"
7 #include "ppapi/c/pp_size.h"
8 #include "ppapi/c/ppb_image_data.h"
9 #include "ppapi/c/ppb_instance.h"
10 #include "ppapi/c/ppb_graphics_2d.h"
12 #include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
13 #include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
18 // Tests PPB_Instance::IsFullFrame().
19 void TestIsFullFrame() {
20 // Note: IsFullFrame returning PP_TRUE is only possible when a plugin
21 // is a content handler. For coverage, see:
22 // tests/ppapi_browser/extension_mime_handler/
23 PP_Bool full_frame
= PPBInstance()->IsFullFrame(pp_instance());
24 EXPECT(full_frame
== PP_FALSE
);
26 full_frame
= PPBInstance()->IsFullFrame(kInvalidInstance
);
27 EXPECT(full_frame
== PP_FALSE
);
32 void TestBindGraphics() {
33 PP_Size size
= PP_MakeSize(100, 100);
35 PP_Resource graphics1
= PPBGraphics2D()->Create(
36 pp_instance(), &size
, PP_TRUE
);
37 PP_Resource graphics2
= PPBGraphics2D()->Create(
38 pp_instance(), &size
, PP_TRUE
);
40 EXPECT(graphics1
!= kInvalidResource
);
41 EXPECT(graphics2
!= kInvalidResource
);
43 PP_Bool ret
= PPBInstance()->BindGraphics(pp_instance(), graphics1
);
44 EXPECT(ret
== PP_TRUE
);
46 // We should be allowed to replace one device with another.
47 ret
= PPBInstance()->BindGraphics(pp_instance(), graphics2
);
48 EXPECT(ret
== PP_TRUE
);
50 // This should fail because instance is not valid.
51 ret
= PPBInstance()->BindGraphics(kInvalidInstance
, graphics1
);
52 EXPECT(ret
== PP_FALSE
);
54 // This should fail because instance is not valid and graphics2 is bound.
55 ret
= PPBInstance()->BindGraphics(kInvalidInstance
, graphics2
);
56 EXPECT(ret
== PP_FALSE
);
58 // This is not a failure, binding resource 0 simply unbinds all devices.
59 ret
= PPBInstance()->BindGraphics(pp_instance(), kInvalidResource
);
60 EXPECT(ret
== PP_TRUE
);
62 PP_Resource image_data
= PPBImageData()->Create(
63 pp_instance(), PP_IMAGEDATAFORMAT_RGBA_PREMUL
, &size
, PP_FALSE
);
64 EXPECT(image_data
!= kInvalidResource
);
66 // This should fail because the resource is the wrong type.
67 ret
= PPBInstance()->BindGraphics(pp_instance(), image_data
);
68 EXPECT(ret
== PP_FALSE
);
76 RegisterTest("TestIsFullFrame", TestIsFullFrame
);
77 RegisterTest("TestBindGraphics", TestBindGraphics
);
80 void SetupPluginInterfaces() {