1 : /* ***** BEGIN LICENSE BLOCK *****
2 : *
3 : * Copyright (c) 2008, Mozilla Corporation
4 : * All rights reserved.
5 : *
6 : * Redistribution and use in source and binary forms, with or without
7 : * modification, are permitted provided that the following conditions are met:
8 : *
9 : * * Redistributions of source code must retain the above copyright notice, this
10 : * list of conditions and the following disclaimer.
11 : * * Redistributions in binary form must reproduce the above copyright notice,
12 : * this list of conditions and the following disclaimer in the documentation
13 : * and/or other materials provided with the distribution.
14 : * * Neither the name of the Mozilla Corporation nor the names of its
15 : * contributors may be used to endorse or promote products derived from this
16 : * software without specific prior written permission.
17 : *
18 : * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 : * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 : * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 : * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22 : * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 : * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 : * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 : * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 : * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 : * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 : *
29 : * Contributor(s):
30 : * Josh Aas <josh@mozilla.com>
31 : *
32 : * ***** END LICENSE BLOCK ***** */
33 :
34 : #ifndef nptest_h_
35 : #define nptest_h_
36 :
37 : #include "mozilla-config.h"
38 :
39 : #include "npapi.h"
40 : #include "npfunctions.h"
41 : #include "npruntime.h"
42 : #include "prtypes.h"
43 : #include <string>
44 : #include <sstream>
45 :
46 : typedef enum {
47 : DM_DEFAULT,
48 : DM_SOLID_COLOR
49 : } DrawMode;
50 :
51 : typedef enum {
52 : FUNCTION_NONE,
53 : FUNCTION_NPP_GETURL,
54 : FUNCTION_NPP_GETURLNOTIFY,
55 : FUNCTION_NPP_POSTURL,
56 : FUNCTION_NPP_POSTURLNOTIFY,
57 : FUNCTION_NPP_NEWSTREAM,
58 : FUNCTION_NPP_WRITEREADY,
59 : FUNCTION_NPP_WRITE,
60 : FUNCTION_NPP_DESTROYSTREAM,
61 : FUNCTION_NPP_WRITE_RPC
62 : } TestFunction;
63 :
64 : typedef enum {
65 : AD_NONE,
66 : AD_BITMAP
67 : } AsyncDrawing;
68 :
69 : typedef enum {
70 : ACTIVATION_STATE_UNKNOWN,
71 : ACTIVATION_STATE_ACTIVATED,
72 : ACTIVATION_STATE_DEACTIVATED
73 : } ActivationState;
74 :
75 : typedef struct FunctionTable {
76 : TestFunction funcId;
77 : const char* funcName;
78 : } FunctionTable;
79 :
80 : typedef enum {
81 : POSTMODE_FRAME,
82 : POSTMODE_STREAM
83 : } PostMode;
84 :
85 : typedef struct TestNPObject : NPObject {
86 : NPP npp;
87 : DrawMode drawMode;
88 : PRUint32 drawColor; // 0xAARRGGBB
89 : } TestNPObject;
90 :
91 : typedef struct _PlatformData PlatformData;
92 :
93 : typedef struct TestRange : NPByteRange {
94 : bool waiting;
95 : } TestRange;
96 :
97 0 : typedef struct InstanceData {
98 : NPP npp;
99 : NPWindow window;
100 : TestNPObject* scriptableObject;
101 : PlatformData* platformData;
102 : int32_t instanceCountWatchGeneration;
103 : bool lastReportedPrivateModeState;
104 : bool hasWidget;
105 : bool npnNewStream;
106 : bool throwOnNextInvoke;
107 : bool runScriptOnPaint;
108 : uint32_t timerID[2];
109 : bool timerTestResult;
110 : bool asyncCallbackResult;
111 : bool invalidateDuringPaint;
112 : int32_t winX;
113 : int32_t winY;
114 : int32_t lastMouseX;
115 : int32_t lastMouseY;
116 : int32_t widthAtLastPaint;
117 : int32_t paintCount;
118 : int32_t writeCount;
119 : int32_t writeReadyCount;
120 : int32_t asyncTestPhase;
121 : TestFunction testFunction;
122 : TestFunction functionToFail;
123 : NPError failureCode;
124 : NPObject* callOnDestroy;
125 : PostMode postMode;
126 : std::string testUrl;
127 : std::string frame;
128 : std::string timerTestScriptCallback;
129 : std::string asyncTestScriptCallback;
130 : std::ostringstream err;
131 : uint16_t streamMode;
132 : int32_t streamChunkSize;
133 : int32_t streamBufSize;
134 : int32_t fileBufSize;
135 : TestRange* testrange;
136 : void* streamBuf;
137 : void* fileBuf;
138 : bool crashOnDestroy;
139 : bool cleanupWidget;
140 : ActivationState topLevelWindowActivationState;
141 : int32_t topLevelWindowActivationEventCount;
142 : ActivationState focusState;
143 : int32_t focusEventCount;
144 : int32_t eventModel;
145 : bool closeStream;
146 : std::string lastKeyText;
147 : bool wantsAllStreams;
148 : AsyncDrawing asyncDrawing;
149 : NPAsyncSurface *frontBuffer;
150 : NPAsyncSurface *backBuffer;
151 : } InstanceData;
152 :
153 : void notifyDidPaint(InstanceData* instanceData);
154 :
155 : #endif // nptest_h_
|