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

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

Issue 791923003: replace COMPILE_ASSERT with static_assert in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixups Created 5 years, 11 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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_url2_test.h" 5 #include "content/test/plugin/plugin_get_javascript_url2_test.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 8
9 // url for "self". 9 // url for "self".
10 #define SELF_URL "javascript:window.location+\"\"" 10 #define SELF_URL "javascript:window.location+\"\""
(...skipping 26 matching lines...) Expand all
37 return NPERR_NO_ERROR; 37 return NPERR_NO_ERROR;
38 } 38 }
39 39
40 NPError ExecuteGetJavascriptUrl2Test::NewStream(NPMIMEType type, NPStream* strea m, 40 NPError ExecuteGetJavascriptUrl2Test::NewStream(NPMIMEType type, NPStream* strea m,
41 NPBool seekable, uint16* stype) { 41 NPBool seekable, uint16* stype) {
42 if (stream == NULL) { 42 if (stream == NULL) {
43 SetError("NewStream got null stream"); 43 SetError("NewStream got null stream");
44 return NPERR_INVALID_PARAM; 44 return NPERR_INVALID_PARAM;
45 } 45 }
46 46
47 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), 47 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
48 cast_validity_check); 48 "cast validity check");
49 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); 49 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
50 switch (stream_id) { 50 switch (stream_id) {
51 case SELF_URL_STREAM_ID: 51 case SELF_URL_STREAM_ID:
52 break; 52 break;
53 default: 53 default:
54 SetError("Unexpected NewStream callback"); 54 SetError("Unexpected NewStream callback");
55 break; 55 break;
56 } 56 }
57 return NPERR_NO_ERROR; 57 return NPERR_NO_ERROR;
58 } 58 }
59 59
60 int32 ExecuteGetJavascriptUrl2Test::WriteReady(NPStream *stream) { 60 int32 ExecuteGetJavascriptUrl2Test::WriteReady(NPStream *stream) {
61 return STREAM_CHUNK; 61 return STREAM_CHUNK;
62 } 62 }
63 63
64 int32 ExecuteGetJavascriptUrl2Test::Write(NPStream *stream, int32 offset, int32 len, 64 int32 ExecuteGetJavascriptUrl2Test::Write(NPStream *stream, int32 offset, int32 len,
65 void *buffer) { 65 void *buffer) {
66 if (stream == NULL) { 66 if (stream == NULL) {
67 SetError("Write got null stream"); 67 SetError("Write got null stream");
68 return -1; 68 return -1;
69 } 69 }
70 if (len < 0 || len > STREAM_CHUNK) { 70 if (len < 0 || len > STREAM_CHUNK) {
71 SetError("Write got bogus stream chunk size"); 71 SetError("Write got bogus stream chunk size");
72 return -1; 72 return -1;
73 } 73 }
74 74
75 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), 75 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
76 cast_validity_check); 76 "cast validity check");
77 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); 77 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
78 switch (stream_id) { 78 switch (stream_id) {
79 case SELF_URL_STREAM_ID: 79 case SELF_URL_STREAM_ID:
80 self_url_.append(static_cast<char*>(buffer), len); 80 self_url_.append(static_cast<char*>(buffer), len);
81 break; 81 break;
82 default: 82 default:
83 SetError("Unexpected write callback"); 83 SetError("Unexpected write callback");
84 break; 84 break;
85 } 85 }
86 // Pretend that we took all the data. 86 // Pretend that we took all the data.
87 return len; 87 return len;
88 } 88 }
89 89
90 90
91 NPError ExecuteGetJavascriptUrl2Test::DestroyStream(NPStream *stream, NPError re ason) { 91 NPError ExecuteGetJavascriptUrl2Test::DestroyStream(NPStream *stream, NPError re ason) {
92 if (stream == NULL) { 92 if (stream == NULL) {
93 SetError("NewStream got null stream"); 93 SetError("NewStream got null stream");
94 return NPERR_INVALID_PARAM; 94 return NPERR_INVALID_PARAM;
95 } 95 }
96 96
97 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(stream->notifyData), 97 static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData),
98 cast_validity_check); 98 "cast validity check");
99 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData); 99 unsigned long stream_id = reinterpret_cast<unsigned long>(stream->notifyData);
100 switch (stream_id) { 100 switch (stream_id) {
101 case SELF_URL_STREAM_ID: 101 case SELF_URL_STREAM_ID:
102 // don't care 102 // don't care
103 break; 103 break;
104 default: 104 default:
105 SetError("Unexpected NewStream callback"); 105 SetError("Unexpected NewStream callback");
106 break; 106 break;
107 } 107 }
108 return NPERR_NO_ERROR; 108 return NPERR_NO_ERROR;
109 } 109 }
110 110
111 void ExecuteGetJavascriptUrl2Test::URLNotify(const char* url, NPReason reason, v oid* data) { 111 void ExecuteGetJavascriptUrl2Test::URLNotify(const char* url, NPReason reason, v oid* data) {
112 COMPILE_ASSERT(sizeof(unsigned long) <= sizeof(data), 112 static_assert(sizeof(unsigned long) <= sizeof(data),
113 cast_validity_check); 113 "cast validity check");
114 114
115 unsigned long stream_id = reinterpret_cast<unsigned long>(data); 115 unsigned long stream_id = reinterpret_cast<unsigned long>(data);
116 switch (stream_id) { 116 switch (stream_id) {
117 case SELF_URL_STREAM_ID: 117 case SELF_URL_STREAM_ID:
118 if (strcmp(url, SELF_URL) != 0) 118 if (strcmp(url, SELF_URL) != 0)
119 SetError("URLNotify reported incorrect url for SELF_URL"); 119 SetError("URLNotify reported incorrect url for SELF_URL");
120 if (self_url_.empty()) 120 if (self_url_.empty())
121 SetError("Failed to obtain window location."); 121 SetError("Failed to obtain window location.");
122 SignalTestCompleted(); 122 SignalTestCompleted();
123 break; 123 break;
124 default: 124 default:
125 SetError("Unexpected NewStream callback"); 125 SetError("Unexpected NewStream callback");
126 break; 126 break;
127 } 127 }
128 } 128 }
129 129
130 } // namespace NPAPIClient 130 } // namespace NPAPIClient
OLDNEW
« no previous file with comments | « content/renderer/render_widget.cc ('k') | content/test/plugin/plugin_get_javascript_url_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698