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.
7 * This file contains interface functions used for unit testing. Do not use in
8 * production code. They are not guaranteed to be available in normal plugin
9 * environments so you should not depend on them.
16 interface PPB_Testing_Private
{
18 * Reads the bitmap data out of the backing store for the given
19 * DeviceContext2D and into the given image. If the data was successfully
20 * read, it will return PP_TRUE.
22 * This function should not generally be necessary for normal plugin
23 * operation. If you want to update portions of a device, the expectation is
24 * that you will either regenerate the data, or maintain a backing store
25 * pushing updates to the device from your backing store via PaintImageData.
26 * Using this function will introduce an extra copy which will make your
27 * plugin slower. In some cases, this may be a very expensive operation (it
28 * may require slow cross-process transitions or graphics card readbacks).
30 * Data will be read into the image starting at |top_left| in the device
31 * context, and proceeding down and to the right for as many pixels as the
32 * image is large. If any part of the image bound would fall outside of the
33 * backing store of the device if positioned at |top_left|, this function
34 * will fail and return PP_FALSE.
36 * The image format must be of the format
37 * PPB_ImageData.GetNativeImageDataFormat() or this function will fail and
40 * The returned image data will represent the current status of the backing
41 * store. This will not include any paint, scroll, or replace operations
42 * that have not yet been flushed; these operations are only reflected in
43 * the backing store (and hence ReadImageData) until after a Flush()
44 * operation has completed.
46 PP_Bool ReadImageData
([in] PP_Resource device_context_2d
,
47 [in] PP_Resource image
,
48 [in] PP_Point top_left
);
51 * Runs a nested message loop. The plugin will be reentered from this call.
52 * This function is used for unit testing the API. The normal pattern is to
53 * issue some asynchronous call that has a callback. Then you call
54 * RunMessageLoop which will suspend the plugin and go back to processing
55 * messages, giving the asynchronous operation time to complete. In your
56 * callback, you save the data and call QuitMessageLoop, which will then
57 * pop back up and continue with the test. This avoids having to write a
58 * complicated state machine for simple tests for asynchronous APIs.
60 void RunMessageLoop
([in] PP_Instance instance
);
63 * Posts a quit message for the outermost nested message loop. Use this to
64 * exit and return back to the caller after you call RunMessageLoop.
66 void QuitMessageLoop
([in] PP_Instance instance
);
69 * Returns the number of live objects (resources + strings + objects)
70 * associated with this plugin instance. Used for detecting leaks. Returns
71 * (uint32_t)-1 on failure.
73 uint32_t GetLiveObjectsForInstance
([in] PP_Instance instance
);
76 * Returns PP_TRUE if the plugin is running out-of-process, PP_FALSE
79 PP_Bool IsOutOfProcess
();
82 * Posts the plugin's current Power Saver status to JavaScript. The plugin
83 * itself does not recieve anything. This is not idiomatic for Pepper,
84 * but convenient for testing.
86 void PostPowerSaverStatus
([in] PP_Instance instance
);
89 * Subscribes to changes to the plugin's Power Saver status. The status
90 * changes are not forwarded to the plugin itself, but posted to JavaScript.
91 * This is not idiomatic for Pepper, but conveienent for testing.
93 void SubscribeToPowerSaverNotifications
([in] PP_Instance instance
);
96 * Passes the input event to the browser, which sends it back to the
97 * plugin. The plugin should implement PPP_InputEvent and register for
98 * the input event type.
100 * This method sends an input event through the browser just as if it had
101 * come from the user. If the browser determines that it is an event for the
102 * plugin, it will be sent to be handled by the plugin's PPP_InputEvent
103 * interface. When generating mouse events, make sure the position is within
104 * the plugin's area on the page. When generating a keyboard event, make sure
105 * the plugin is focused.
107 * Note that the browser may generate extra input events in order to
108 * maintain certain invariants, such as always having a "mouse enter" event
109 * before any other mouse event. Furthermore, the event the plugin receives
110 * after sending a simulated event will be slightly different from the
111 * original event. The browser may change the timestamp, add modifiers, and
112 * slightly alter the mouse position, due to coordinate transforms it
115 void SimulateInputEvent
([in] PP_Instance instance
,
116 [in] PP_Resource input_event
);
119 * Returns the URL for the document. This is a safe way to retrieve
120 * window.location.href.
121 * If the canonicalized URL is valid, the method will parse the URL
122 * and fill in the components structure. This pointer may be NULL
123 * to specify that no component information is necessary.
125 PP_Var GetDocumentURL
([in] PP_Instance instance
,
126 [out] PP_URLComponents_Dev components
);
129 * Fetches up to |array_size| active PP_Vars in the tracker. Returns the
130 * number of vars in the tracker. The active vars are written to |live_vars|
131 * contiguously starting at index 0. The vars are not in any particular order.
132 * If the number of live vars is greater than |array_size|, then an arbitrary
133 * subset of |array_size| vars is written to |live_vars|. The reference count
134 * of the returned PP_Vars will *not* be affected by this call.
136 uint32_t GetLiveVars
([size_as
=array_size
] PP_Var
[] live_vars
,
137 [in] uint32_t array_size
);
140 * Sets the threshold size at which point we switch from transmitting
141 * array buffers in IPC messages to using shared memory. This is only used
142 * for testing purposes where we need to transmit small buffers using shmem
143 * (in order to have fast tests). Passing a value of 0 resets the threshold
144 * to its default. The threshold is in bytes.
146 void SetMinimumArrayBufferSizeForShmem
([in] PP_Instance instance
,
147 [in] uint32_t threshold
);
150 * Run the V8 garbage collector for tests.
152 void RunV8GC
([in] PP_Instance instance
);