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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <atlcom.h> | 6 #include <atlcom.h> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/win/scoped_comptr.h" | 10 #include "base/win/scoped_comptr.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 ASSERT_TRUE(ReadFileAsString(kSmallHtmlMetaTag, &small_html_meta_tag)); | 166 ASSERT_TRUE(ReadFileAsString(kSmallHtmlMetaTag, &small_html_meta_tag)); |
167 ASSERT_TRUE(StringToStream(small_html_meta_tag, stream_with_meta.Receive())); | 167 ASSERT_TRUE(StringToStream(small_html_meta_tag, stream_with_meta.Receive())); |
168 EXPECT_HRESULT_SUCCEEDED(sniffer.ReadIntoCache(stream_with_meta, true)); | 168 EXPECT_HRESULT_SUCCEEDED(sniffer.ReadIntoCache(stream_with_meta, true)); |
169 | 169 |
170 CComObjectStackEx<MockBindStatusCallbackImpl> mock; | 170 CComObjectStackEx<MockBindStatusCallbackImpl> mock; |
171 const CLIPFORMAT cf = 0xd0d0; | 171 const CLIPFORMAT cf = 0xd0d0; |
172 const DWORD flags = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION; | 172 const DWORD flags = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION; |
173 const DWORD data_size = small_html_meta_tag.size(); | 173 const DWORD data_size = small_html_meta_tag.size(); |
174 | 174 |
175 DWORD read_size1 = data_size * 2; | 175 DWORD read_size1 = data_size * 2; |
176 scoped_ptr<char> read_buffer1(new char[read_size1]); | 176 scoped_array<char> read_buffer1(new char[read_size1]); |
177 ZeroMemory(read_buffer1.get(), read_size1); | 177 ZeroMemory(read_buffer1.get(), read_size1); |
178 | 178 |
179 char read_buffer2[10] = {0}; | 179 char read_buffer2[10] = {0}; |
180 DWORD read_size2 = sizeof(read_buffer2); | 180 DWORD read_size2 = sizeof(read_buffer2); |
181 HRESULT ret1 = E_FAIL, ret2 = E_FAIL; | 181 HRESULT ret1 = E_FAIL, ret2 = E_FAIL; |
182 | 182 |
183 EXPECT_CALL(mock, OnDataAvailable(flags, data_size, | 183 EXPECT_CALL(mock, OnDataAvailable(flags, data_size, |
184 testing::Field(&FORMATETC::cfFormat, cf), | 184 testing::Field(&FORMATETC::cfFormat, cf), |
185 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) | 185 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) |
186 .WillOnce(testing::DoAll( | 186 .WillOnce(testing::DoAll( |
(...skipping 23 matching lines...) Expand all Loading... |
210 ASSERT_TRUE(StringToStream(small_html_meta_tag, stream_with_meta.Receive())); | 210 ASSERT_TRUE(StringToStream(small_html_meta_tag, stream_with_meta.Receive())); |
211 EXPECT_HRESULT_SUCCEEDED(sniffer.ReadIntoCache(stream_with_meta, true)); | 211 EXPECT_HRESULT_SUCCEEDED(sniffer.ReadIntoCache(stream_with_meta, true)); |
212 | 212 |
213 CComObjectStackEx<MockBindStatusCallbackImpl> mock; | 213 CComObjectStackEx<MockBindStatusCallbackImpl> mock; |
214 const CLIPFORMAT cf = 0xd0d0; | 214 const CLIPFORMAT cf = 0xd0d0; |
215 const DWORD flags = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION; | 215 const DWORD flags = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION; |
216 const DWORD data_size = small_html_meta_tag.size(); | 216 const DWORD data_size = small_html_meta_tag.size(); |
217 | 217 |
218 DWORD read_size1 = data_size / 2; // First read is half the data. | 218 DWORD read_size1 = data_size / 2; // First read is half the data. |
219 DWORD read_size2 = data_size; // Second read, try to read past data. | 219 DWORD read_size2 = data_size; // Second read, try to read past data. |
220 scoped_ptr<char> read_buffer1(new char[read_size1]); | 220 scoped_array<char> read_buffer1(new char[read_size1]); |
221 scoped_ptr<char> read_buffer2(new char[read_size2]); | 221 scoped_array<char> read_buffer2(new char[read_size2]); |
222 ZeroMemory(read_buffer1.get(), read_size1); | 222 ZeroMemory(read_buffer1.get(), read_size1); |
223 ZeroMemory(read_buffer2.get(), read_size2); | 223 ZeroMemory(read_buffer2.get(), read_size2); |
224 | 224 |
225 char read_buffer3[10] = {0}; | 225 char read_buffer3[10] = {0}; |
226 DWORD read_size3 = sizeof(read_buffer3); | 226 DWORD read_size3 = sizeof(read_buffer3); |
227 HRESULT ret1 = E_FAIL, ret2 = E_FAIL, ret3 = E_FAIL; | 227 HRESULT ret1 = E_FAIL, ret2 = E_FAIL, ret3 = E_FAIL; |
228 | 228 |
229 EXPECT_CALL(mock, OnDataAvailable(flags, data_size, | 229 EXPECT_CALL(mock, OnDataAvailable(flags, data_size, |
230 testing::Field(&FORMATETC::cfFormat, cf), | 230 testing::Field(&FORMATETC::cfFormat, cf), |
231 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) | 231 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) |
(...skipping 12 matching lines...) Expand all Loading... |
244 | 244 |
245 std::string data_read; | 245 std::string data_read; |
246 data_read.append(read_buffer1.get(), read_size1); | 246 data_read.append(read_buffer1.get(), read_size1); |
247 data_read.append(read_buffer2.get(), read_size2); | 247 data_read.append(read_buffer2.get(), read_size2); |
248 EXPECT_EQ(small_html_meta_tag, data_read); | 248 EXPECT_EQ(small_html_meta_tag, data_read); |
249 | 249 |
250 EXPECT_EQ(S_FALSE, ret3); | 250 EXPECT_EQ(S_FALSE, ret3); |
251 EXPECT_STREQ("", read_buffer3); | 251 EXPECT_STREQ("", read_buffer3); |
252 EXPECT_EQ(sizeof(read_buffer3), read_size3); | 252 EXPECT_EQ(sizeof(read_buffer3), read_size3); |
253 } | 253 } |
OLD | NEW |