Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: content/test/plugin/plugin_get_javascript_url2_test.cc

Issue 1182303010: Delete the NPAPI plugin browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #include "content/test/plugin/plugin_get_javascript_url2_test.h"
6
7 #include "base/basictypes.h"
8
9 // url for "self".
10 #define SELF_URL "javascript:window.location+\"\""
11 // The identifier for the self url stream.
12 #define SELF_URL_STREAM_ID 1
13
14 // The maximum chunk size of stream data.
15 #define STREAM_CHUNK 197
16
17 namespace NPAPIClient {
18
19 ExecuteGetJavascriptUrl2Test::ExecuteGetJavascriptUrl2Test(
20 NPP id, NPNetscapeFuncs *host_functions)
21 : PluginTest(id, host_functions),
22 test_started_(false) {
23 }
24
25 NPError ExecuteGetJavascriptUrl2Test::SetWindow(NPWindow* pNPWindow) {
26 #if !defined(OS_MACOSX)
27 if (pNPWindow->window == NULL)
28 return NPERR_NO_ERROR;
29 #endif
30
31 if (!test_started_) {
32 std::string url = SELF_URL;
33 HostFunctions()->geturlnotify(id(), url.c_str(), "_self",
34 reinterpret_cast<void*>(SELF_URL_STREAM_ID));
35 test_started_ = true;
36 }
37 return NPERR_NO_ERROR;
38 }
39
40 NPError ExecuteGetJavascriptUrl2Test::NewStream(NPMIMEType type, NPStream* strea m,
41 NPBool seekable, uint16* stype) {
42 if (stream == NULL) {
43 SetError("NewStream got null stream");
44 return NPERR_INVALID_PARAM;
45 }
46
47 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
48 "cast validity check");
49 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
50 switch (stream_id) {
51 case SELF_URL_STREAM_ID:
52 break;
53 default:
54 SetError("Unexpected NewStream callback");
55 break;
56 }
57 return NPERR_NO_ERROR;
58 }
59
60 int32 ExecuteGetJavascriptUrl2Test::WriteReady(NPStream *stream) {
61 return STREAM_CHUNK;
62 }
63
64 int32 ExecuteGetJavascriptUrl2Test::Write(NPStream *stream, int32 offset, int32 len,
65 void *buffer) {
66 if (stream == NULL) {
67 SetError("Write got null stream");
68 return -1;
69 }
70 if (len < 0 || len > STREAM_CHUNK) {
71 SetError("Write got bogus stream chunk size");
72 return -1;
73 }
74
75 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
76 "cast validity check");
77 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
78 switch (stream_id) {
79 case SELF_URL_STREAM_ID:
80 self_url_.append(static_cast<char*>(buffer), len);
81 break;
82 default:
83 SetError("Unexpected write callback");
84 break;
85 }
86 // Pretend that we took all the data.
87 return len;
88 }
89
90
91 NPError ExecuteGetJavascriptUrl2Test::DestroyStream(NPStream *stream, NPError re ason) {
92 if (stream == NULL) {
93 SetError("NewStream got null stream");
94 return NPERR_INVALID_PARAM;
95 }
96
97 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
98 "cast validity check");
99 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
100 switch (stream_id) {
101 case SELF_URL_STREAM_ID:
102 // don't care
103 break;
104 default:
105 SetError("Unexpected NewStream callback");
106 break;
107 }
108 return NPERR_NO_ERROR;
109 }
110
111 void ExecuteGetJavascriptUrl2Test::URLNotify(const char* url, NPReason reason, v oid* data) {
112 static_assert(sizeof(unsigned long) <= sizeof(data),
113 "cast validity check");
114
115 unsigned long stream_id = reinterpret_cast<unsigned long>(data);
116 switch (stream_id) {
117 case SELF_URL_STREAM_ID:
118 if (strcmp(url, SELF_URL) != 0)
119 SetError("URLNotify reported incorrect url for SELF_URL");
120 if (self_url_.empty())
121 SetError("Failed to obtain window location.");
122 SignalTestCompleted();
123 break;
124 default:
125 SetError("Unexpected NewStream callback");
126 break;
127 }
128 }
129
130 } // namespace NPAPIClient
OLDNEW
« no previous file with comments | « content/test/plugin/plugin_get_javascript_url2_test.h ('k') | content/test/plugin/plugin_get_javascript_url_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698