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