Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / chrome / test / data / nacl / ppapi / ppp_instance / ppapi_ppp_instance.cc
blob9ad5a476501eb5cc5e891b10f94bf1ce0b0bb43a
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 <string.h>
7 #include <vector>
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"
21 namespace {
23 PP_Bool DidCreate(PP_Instance instance,
24 uint32_t argc,
25 const char* argn[],
26 const char* argv[]) {
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.
32 return status;
35 // This should never be called.
36 void DidDestroy(PP_Instance instance) {
37 printf("--- PPP_Instance::DidDestroy\n");
38 CHECK(instance == pp_instance());
39 NACL_NOTREACHED();
42 void DidChangeView(PP_Instance instance, PP_Resource view) {
43 printf("--- PPP_Instance::DidChangeView\n");
44 EXPECT(instance == pp_instance());
46 PP_Rect clip;
47 PPBView()->GetClipRect(view, &clip);
48 EXPECT(clip.point.x == 0 && clip.point.y == 0);
50 // These are based on embed dimensions.
51 PP_Rect position;
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);
56 TEST_PASSED;
59 void DidChangeFocus(PP_Instance instance,
60 PP_Bool has_focus) {
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;
69 TEST_PASSED;
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/
76 NACL_NOTREACHED();
77 return PP_FALSE;
80 const PPP_Instance ppp_instance_interface = {
81 DidCreate,
82 DidDestroy,
83 DidChangeView,
84 DidChangeFocus,
85 HandleDocumentLoad
88 } // namespace
91 void SetupTests() {
92 // Each PPP_Instance function called by the browser acts as a test.
95 void SetupPluginInterfaces() {
96 RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface);