| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "native_client/src/include/nacl_macros.h" | 9 #include "native_client/src/include/nacl_macros.h" |
| 10 #include "native_client/src/shared/platform/nacl_check.h" | 10 #include "native_client/src/shared/platform/nacl_check.h" |
| 11 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" | 11 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h" |
| 12 #include "native_client/tests/ppapi_test_lib/test_interface.h" | 12 #include "native_client/tests/ppapi_test_lib/test_interface.h" |
| 13 | 13 |
| 14 #include "ppapi/c/pp_bool.h" | 14 #include "ppapi/c/pp_bool.h" |
| 15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 16 #include "ppapi/c/pp_input_event.h" | 16 #include "ppapi/c/pp_input_event.h" |
| 17 #include "ppapi/c/ppb_view.h" |
| 17 #include "ppapi/c/ppp_instance.h" | 18 #include "ppapi/c/ppp_instance.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 PP_Bool DidCreate(PP_Instance instance, | 22 PP_Bool DidCreate(PP_Instance instance, |
| 22 uint32_t argc, | 23 uint32_t argc, |
| 23 const char* argn[], | 24 const char* argn[], |
| 24 const char* argv[]) { | 25 const char* argv[]) { |
| 25 printf("--- PPP_Instance::DidCreate\n"); | 26 printf("--- PPP_Instance::DidCreate\n"); |
| 26 PP_Bool status = DidCreateDefault(instance, argc, argn, argv); | 27 PP_Bool status = DidCreateDefault(instance, argc, argn, argv); |
| 27 // TEST_PASSED has no effect from this function. | 28 // 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 // But as long as the plugin loads and tests are run, we know this succeeded. |
| 29 // See ppapi_browser/bad for failing DidCreate. | 30 // See ppapi_browser/bad for failing DidCreate. |
| 30 return status; | 31 return status; |
| 31 } | 32 } |
| 32 | 33 |
| 33 // This should never be called. | 34 // This should never be called. |
| 34 void DidDestroy(PP_Instance instance) { | 35 void DidDestroy(PP_Instance instance) { |
| 35 printf("--- PPP_Instance::DidDestroy\n"); | 36 printf("--- PPP_Instance::DidDestroy\n"); |
| 36 CHECK(instance == pp_instance()); | 37 CHECK(instance == pp_instance()); |
| 37 NACL_NOTREACHED(); | 38 NACL_NOTREACHED(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void DidChangeView(PP_Instance instance, | 41 void DidChangeView(PP_Instance instance, PP_Resource view) { |
| 41 const struct PP_Rect* position, | |
| 42 const struct PP_Rect* clip) { | |
| 43 printf("--- PPP_Instance::DidChangeView\n"); | 42 printf("--- PPP_Instance::DidChangeView\n"); |
| 44 EXPECT(instance == pp_instance()); | 43 EXPECT(instance == pp_instance()); |
| 45 EXPECT(clip->point.x == 0 && clip->point.y == 0); | 44 |
| 45 PP_Rect clip; |
| 46 PPBView()->GetClipRect(view, &clip); |
| 47 EXPECT(clip.point.x == 0 && clip.point.y == 0); |
| 48 |
| 46 // These are based on embed dimensions. | 49 // These are based on embed dimensions. |
| 47 EXPECT(position->size.width == 15 && clip->size.width == 15); | 50 PP_Rect position; |
| 48 EXPECT(position->size.height == 20 && clip->size.height == 20); | 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); |
| 49 | 54 |
| 50 TEST_PASSED; | 55 TEST_PASSED; |
| 51 } | 56 } |
| 52 | 57 |
| 53 void DidChangeFocus(PP_Instance instance, | 58 void DidChangeFocus(PP_Instance instance, |
| 54 PP_Bool has_focus) { | 59 PP_Bool has_focus) { |
| 55 printf("--- PPP_Instance::DidChangeFocus has_focus=%d\n", has_focus); | 60 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 | 61 // There should be no focus on load, so this will trigger when we gain it |
| 57 // and then release it and so on. | 62 // and then release it and so on. |
| 58 static bool expected_has_focus = true; | 63 static bool expected_has_focus = true; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 82 } // namespace | 87 } // namespace |
| 83 | 88 |
| 84 | 89 |
| 85 void SetupTests() { | 90 void SetupTests() { |
| 86 // Each PPP_Instance function called by the browser acts as a test. | 91 // Each PPP_Instance function called by the browser acts as a test. |
| 87 } | 92 } |
| 88 | 93 |
| 89 void SetupPluginInterfaces() { | 94 void SetupPluginInterfaces() { |
| 90 RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface); | 95 RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface); |
| 91 } | 96 } |
| OLD | NEW |