OLD | NEW |
(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 <string.h> |
| 6 |
| 7 #include <vector> |
| 8 |
| 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" |
| 13 |
| 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/ppp_instance.h" |
| 18 |
| 19 namespace { |
| 20 |
| 21 PP_Bool DidCreate(PP_Instance instance, |
| 22 uint32_t argc, |
| 23 const char* argn[], |
| 24 const char* argv[]) { |
| 25 printf("--- PPP_Instance::DidCreate\n"); |
| 26 PP_Bool status = DidCreateDefault(instance, argc, argn, argv); |
| 27 // TEST_PASSED has no effect from this function. |
| 28 // But as long as the plugin loads and tests are run, we know this succeeded. |
| 29 // See ppapi_browser/bad for failing DidCreate. |
| 30 return status; |
| 31 } |
| 32 |
| 33 // This should never be called. |
| 34 void DidDestroy(PP_Instance instance) { |
| 35 printf("--- PPP_Instance::DidDestroy\n"); |
| 36 CHECK(instance == pp_instance()); |
| 37 NACL_NOTREACHED(); |
| 38 } |
| 39 |
| 40 void DidChangeView(PP_Instance instance, |
| 41 const struct PP_Rect* position, |
| 42 const struct PP_Rect* clip) { |
| 43 printf("--- PPP_Instance::DidChangeView\n"); |
| 44 EXPECT(instance == pp_instance()); |
| 45 EXPECT(clip->point.x == 0 && clip->point.y == 0); |
| 46 // These are based on embed dimensions. |
| 47 EXPECT(position->size.width == 15 && clip->size.width == 15); |
| 48 EXPECT(position->size.height == 20 && clip->size.height == 20); |
| 49 |
| 50 TEST_PASSED; |
| 51 } |
| 52 |
| 53 void DidChangeFocus(PP_Instance instance, |
| 54 PP_Bool has_focus) { |
| 55 printf("--- PPP_Instance::DidChangeFocus has_focus=%d\n", has_focus); |
| 56 // There should be no focus on load, so this will trigger when we gain it |
| 57 // and then release it and so on. |
| 58 static bool expected_has_focus = true; |
| 59 EXPECT(instance == pp_instance()); |
| 60 EXPECT(has_focus == expected_has_focus); |
| 61 expected_has_focus = !expected_has_focus; |
| 62 |
| 63 TEST_PASSED; |
| 64 } |
| 65 |
| 66 PP_Bool HandleDocumentLoad(PP_Instance instance, |
| 67 PP_Resource url_loader) { |
| 68 // Only called for full-frame plugins. For coverage see: |
| 69 // tests/ppapi_browser/extension_mime_handler/ |
| 70 NACL_NOTREACHED(); |
| 71 return PP_FALSE; |
| 72 } |
| 73 |
| 74 const PPP_Instance ppp_instance_interface = { |
| 75 DidCreate, |
| 76 DidDestroy, |
| 77 DidChangeView, |
| 78 DidChangeFocus, |
| 79 HandleDocumentLoad |
| 80 }; |
| 81 |
| 82 } // namespace |
| 83 |
| 84 |
| 85 void SetupTests() { |
| 86 // Each PPP_Instance function called by the browser acts as a test. |
| 87 } |
| 88 |
| 89 void SetupPluginInterfaces() { |
| 90 RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface); |
| 91 } |
OLD | NEW |