OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_request_read_test.h" | 5 #include "content/test/plugin/plugin_request_read_test.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 | 8 |
9 namespace NPAPIClient { | 9 namespace NPAPIClient { |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 // Shrink range to mark area we have just received. | 85 // Shrink range to mark area we have just received. |
86 it->offset += len; | 86 it->offset += len; |
87 if (static_cast<int32>(it->length) < len) | 87 if (static_cast<int32>(it->length) < len) |
88 it->length = 0; | 88 it->length = 0; |
89 else | 89 else |
90 it->length -= len; | 90 it->length -= len; |
91 if (it->length == 0) | 91 if (it->length == 0) |
92 requested_ranges_.erase(it); | 92 requested_ranges_.erase(it); |
93 | 93 |
94 // Verify that data, which we got, is right. | 94 // Verify the data we got is right. We expect a string like "01234...". |
95 const char* data = static_cast<const char*>(buffer); | 95 const char* data = static_cast<const char*>(buffer); |
96 for (int32 i = 0; i < len; ++i) { | 96 for (int32 i = 0; i < len; ++i) { |
97 int cur_offset = offset + i; | 97 char expected = '0' + static_cast<char>(offset + i); |
98 char expected = '0' + cur_offset; | |
99 if (data[i] != expected) { | 98 if (data[i] != expected) { |
100 SetError("Content mismatch between data and source!"); | 99 SetError("Content mismatch between data and source!"); |
101 break; | 100 break; |
102 } | 101 } |
103 } | 102 } |
104 if (requested_ranges_.empty()) | 103 if (requested_ranges_.empty()) |
105 SignalTestCompleted(); | 104 SignalTestCompleted(); |
106 | 105 |
107 return len; | 106 return len; |
108 } | 107 } |
109 | 108 |
110 } // namespace NPAPIClient | 109 } // namespace NPAPIClient |
111 | 110 |
OLD | NEW |