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.
9 #include "native_client/src/include/nacl_macros.h"
10 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_errors.h"
14 #include "ppapi/c/pp_input_event.h"
15 #include "ppapi/c/ppb_view.h"
16 #include "ppapi/c/ppp_instance.h"
18 #include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
19 #include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
23 PP_Bool
DidCreate(PP_Instance instance
,
27 printf("--- PPP_Instance::DidCreate\n");
28 PP_Bool status
= DidCreateDefault(instance
, argc
, argn
, argv
);
29 // TEST_PASSED has no effect from this function.
30 // But as long as the plugin loads and tests are run, we know this succeeded.
31 // See ppapi_browser/bad for failing DidCreate.
35 // This should never be called.
36 void DidDestroy(PP_Instance instance
) {
37 printf("--- PPP_Instance::DidDestroy\n");
38 CHECK(instance
== pp_instance());
42 void DidChangeView(PP_Instance instance
, PP_Resource view
) {
43 printf("--- PPP_Instance::DidChangeView\n");
44 EXPECT(instance
== pp_instance());
47 PPBView()->GetClipRect(view
, &clip
);
48 EXPECT(clip
.point
.x
== 0 && clip
.point
.y
== 0);
50 // These are based on embed dimensions.
52 PPBView()->GetRect(view
, &position
);
53 EXPECT(position
.size
.width
== 15 && clip
.size
.width
== 15);
54 EXPECT(position
.size
.height
== 20 && clip
.size
.height
== 20);
59 void DidChangeFocus(PP_Instance instance
,
61 printf("--- PPP_Instance::DidChangeFocus has_focus=%d\n", has_focus
);
62 // There should be no focus on load, so this will trigger when we gain it
63 // and then release it and so on.
64 static bool expected_has_focus
= true;
65 EXPECT(instance
== pp_instance());
66 EXPECT(has_focus
== expected_has_focus
);
67 expected_has_focus
= !expected_has_focus
;
72 PP_Bool
HandleDocumentLoad(PP_Instance instance
,
73 PP_Resource url_loader
) {
74 // Only called for full-frame plugins. For coverage see:
75 // tests/ppapi_browser/extension_mime_handler/
80 const PPP_Instance ppp_instance_interface
= {
92 // Each PPP_Instance function called by the browser acts as a test.
95 void SetupPluginInterfaces() {
96 RegisterPluginInterface(PPP_INSTANCE_INTERFACE
, &ppp_instance_interface
);