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 "content/test/plugin/plugin_get_javascript_url_test.h" | 5 #include "content/test/plugin/plugin_get_javascript_url_test.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 // url for "self". | 10 // url for "self". |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (stream == NULL) { | 102 if (stream == NULL) { |
103 SetError("NewStream got null stream"); | 103 SetError("NewStream got null stream"); |
104 return NPERR_INVALID_PARAM; | 104 return NPERR_INVALID_PARAM; |
105 } | 105 } |
106 | 106 |
107 if (npn_evaluate_context_) { | 107 if (npn_evaluate_context_) { |
108 SetError("NewStream received in context of NPN_Evaluate"); | 108 SetError("NewStream received in context of NPN_Evaluate"); |
109 return NPERR_NO_ERROR; | 109 return NPERR_NO_ERROR; |
110 } | 110 } |
111 | 111 |
112 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), | 112 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), |
113 cast_validity_check); | 113 "cast validity check"); |
114 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); | 114 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
115 switch (stream_id) { | 115 switch (stream_id) { |
116 case SELF_URL_STREAM_ID: | 116 case SELF_URL_STREAM_ID: |
117 break; | 117 break; |
118 default: | 118 default: |
119 SetError("Unexpected NewStream callback"); | 119 SetError("Unexpected NewStream callback"); |
120 break; | 120 break; |
121 } | 121 } |
122 return NPERR_NO_ERROR; | 122 return NPERR_NO_ERROR; |
123 } | 123 } |
(...skipping 15 matching lines...) Expand all Loading... |
139 if (len < 0 || len > STREAM_CHUNK) { | 139 if (len < 0 || len > STREAM_CHUNK) { |
140 SetError("Write got bogus stream chunk size"); | 140 SetError("Write got bogus stream chunk size"); |
141 return -1; | 141 return -1; |
142 } | 142 } |
143 | 143 |
144 if (npn_evaluate_context_) { | 144 if (npn_evaluate_context_) { |
145 SetError("Write received in context of NPN_Evaluate"); | 145 SetError("Write received in context of NPN_Evaluate"); |
146 return len; | 146 return len; |
147 } | 147 } |
148 | 148 |
149 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), | 149 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), |
150 cast_validity_check); | 150 "cast validity check"); |
151 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); | 151 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
152 switch (stream_id) { | 152 switch (stream_id) { |
153 case SELF_URL_STREAM_ID: | 153 case SELF_URL_STREAM_ID: |
154 self_url_.append(static_cast<char*>(buffer), len); | 154 self_url_.append(static_cast<char*>(buffer), len); |
155 break; | 155 break; |
156 default: | 156 default: |
157 SetError("Unexpected write callback"); | 157 SetError("Unexpected write callback"); |
158 break; | 158 break; |
159 } | 159 } |
160 // Pretend that we took all the data. | 160 // Pretend that we took all the data. |
(...skipping 10 matching lines...) Expand all Loading... |
171 | 171 |
172 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
173 KillTimer(window_, kNPNEvaluateTimerID); | 173 KillTimer(window_, kNPNEvaluateTimerID); |
174 #endif | 174 #endif |
175 | 175 |
176 if (npn_evaluate_context_) { | 176 if (npn_evaluate_context_) { |
177 SetError("DestroyStream received in context of NPN_Evaluate"); | 177 SetError("DestroyStream received in context of NPN_Evaluate"); |
178 return NPERR_NO_ERROR; | 178 return NPERR_NO_ERROR; |
179 } | 179 } |
180 | 180 |
181 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), | 181 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), |
182 cast_validity_check); | 182 "cast validity check"); |
183 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); | 183 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); |
184 switch (stream_id) { | 184 switch (stream_id) { |
185 case SELF_URL_STREAM_ID: | 185 case SELF_URL_STREAM_ID: |
186 // don't care | 186 // don't care |
187 break; | 187 break; |
188 default: | 188 default: |
189 SetError("Unexpected NewStream callback"); | 189 SetError("Unexpected NewStream callback"); |
190 break; | 190 break; |
191 } | 191 } |
192 return NPERR_NO_ERROR; | 192 return NPERR_NO_ERROR; |
193 } | 193 } |
194 | 194 |
195 void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, | 195 void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, |
196 void* data) { | 196 void* data) { |
197 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(data), | 197 static_assert(sizeof(unsigned long) <= sizeof(data), |
198 cast_validity_check); | 198 "cast validity check"); |
199 | 199 |
200 if (npn_evaluate_context_) { | 200 if (npn_evaluate_context_) { |
201 SetError("URLNotify received in context of NPN_Evaluate"); | 201 SetError("URLNotify received in context of NPN_Evaluate"); |
202 return; | 202 return; |
203 } | 203 } |
204 | 204 |
205 unsigned long stream_id = reinterpret_cast<unsigned long>(data); | 205 unsigned long stream_id = reinterpret_cast<unsigned long>(data); |
206 switch (stream_id) { | 206 switch (stream_id) { |
207 case SELF_URL_STREAM_ID: | 207 case SELF_URL_STREAM_ID: |
208 if (strcmp(url, SELF_URL) != 0) | 208 if (strcmp(url, SELF_URL) != 0) |
209 SetError("URLNotify reported incorrect url for SELF_URL"); | 209 SetError("URLNotify reported incorrect url for SELF_URL"); |
210 if (self_url_.empty()) | 210 if (self_url_.empty()) |
211 SetError("Failed to obtain window location."); | 211 SetError("Failed to obtain window location."); |
212 SignalTestCompleted(); | 212 SignalTestCompleted(); |
213 break; | 213 break; |
214 default: | 214 default: |
215 SetError("Unexpected NewStream callback"); | 215 SetError("Unexpected NewStream callback"); |
216 break; | 216 break; |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 } // namespace NPAPIClient | 220 } // namespace NPAPIClient |
OLD | NEW |