OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_comptr_win.h" | 10 #include "base/scoped_comptr_win.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 char ret[2 * sizeof(data)] = {0}; | 67 char ret[2 * sizeof(data)] = {0}; |
68 DWORD read = 0; | 68 DWORD read = 0; |
69 | 69 |
70 // Test 1: empty stream reads nothing | 70 // Test 1: empty stream reads nothing |
71 CComObjectStackEx<CacheStream> cache_stream1; | 71 CComObjectStackEx<CacheStream> cache_stream1; |
72 EXPECT_EQ(E_PENDING, cache_stream1.Read(ret, sizeof(ret), &read)); | 72 EXPECT_EQ(E_PENDING, cache_stream1.Read(ret, sizeof(ret), &read)); |
73 EXPECT_EQ(0, read); | 73 EXPECT_EQ(0, read); |
74 | 74 |
75 // Test 2: Read from initialized cache | 75 // Test 2: Read from initialized cache |
76 CComObjectStackEx<CacheStream> cache_stream2; | 76 CComObjectStackEx<CacheStream> cache_stream2; |
77 cache_stream2.Initialize(data, sizeof(data)); | 77 cache_stream2.Initialize(data, sizeof(data), false); |
78 EXPECT_HRESULT_SUCCEEDED(cache_stream2.Read(ret, sizeof(ret), &read)); | 78 EXPECT_HRESULT_SUCCEEDED(cache_stream2.Read(ret, sizeof(ret), &read)); |
79 EXPECT_EQ(sizeof(data), read); | 79 EXPECT_EQ(sizeof(data), read); |
80 EXPECT_EQ(std::string(data), std::string(ret)); | 80 EXPECT_EQ(std::string(data), std::string(ret)); |
81 | 81 |
82 read = 0; | 82 read = 0; |
83 EXPECT_EQ(E_PENDING, cache_stream2.Read(ret, sizeof(ret), &read)); | 83 EXPECT_EQ(E_PENDING, cache_stream2.Read(ret, sizeof(ret), &read)); |
84 EXPECT_EQ(0, read); | 84 EXPECT_EQ(0, read); |
85 } | 85 } |
86 | 86 |
87 ACTION_P3(ReadStream, buffer, size, ret) { | 87 ACTION_P3(ReadStream, buffer, size, ret) { |
(...skipping 17 matching lines...) Expand all Loading... |
105 | 105 |
106 EXPECT_CALL(mock, OnDataAvailable(flags, size, | 106 EXPECT_CALL(mock, OnDataAvailable(flags, size, |
107 testing::Field(&FORMATETC::cfFormat, cf), | 107 testing::Field(&FORMATETC::cfFormat, cf), |
108 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) | 108 testing::Field(&STGMEDIUM::tymed, TYMED_ISTREAM))) |
109 .WillOnce(testing::DoAll( | 109 .WillOnce(testing::DoAll( |
110 ReadStream(read_buffer1, &read_size1, &ret1), | 110 ReadStream(read_buffer1, &read_size1, &ret1), |
111 ReadStream(read_buffer2, &read_size2, &ret2), | 111 ReadStream(read_buffer2, &read_size2, &ret2), |
112 Return(S_OK))); | 112 Return(S_OK))); |
113 | 113 |
114 EXPECT_HRESULT_SUCCEEDED(CacheStream::BSCBFeedData(&mock, data, size, cf, | 114 EXPECT_HRESULT_SUCCEEDED(CacheStream::BSCBFeedData(&mock, data, size, cf, |
115 flags)); | 115 flags, false)); |
116 | 116 |
117 EXPECT_HRESULT_SUCCEEDED(ret1); | 117 EXPECT_HRESULT_SUCCEEDED(ret1); |
118 EXPECT_STREQ(data, read_buffer1); | 118 EXPECT_STREQ(data, read_buffer1); |
119 EXPECT_EQ(size, read_size1); | 119 EXPECT_EQ(size, read_size1); |
120 | 120 |
121 EXPECT_EQ(E_PENDING, ret2); | 121 EXPECT_EQ(E_PENDING, ret2); |
122 EXPECT_STREQ("", read_buffer2); | 122 EXPECT_STREQ("", read_buffer2); |
123 EXPECT_EQ(kArbitraryreadSize, read_size2); | 123 EXPECT_EQ(kArbitraryreadSize, read_size2); |
124 } | 124 } |
125 | 125 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 240 |
241 std::string data_read; | 241 std::string data_read; |
242 data_read.append(read_buffer1.get(), read_size1); | 242 data_read.append(read_buffer1.get(), read_size1); |
243 data_read.append(read_buffer2.get(), read_size2); | 243 data_read.append(read_buffer2.get(), read_size2); |
244 EXPECT_EQ(small_html_meta_tag, data_read); | 244 EXPECT_EQ(small_html_meta_tag, data_read); |
245 | 245 |
246 EXPECT_EQ(E_PENDING, ret3); | 246 EXPECT_EQ(E_PENDING, ret3); |
247 EXPECT_STREQ("", read_buffer3); | 247 EXPECT_STREQ("", read_buffer3); |
248 EXPECT_EQ(sizeof(read_buffer3), read_size3); | 248 EXPECT_EQ(sizeof(read_buffer3), read_size3); |
249 } | 249 } |
OLD | NEW |