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

Side by Side Diff: components/dom_distiller/core/dom_distiller_service_unittest.cc

Issue 396503003: DomDistiller: fix 0 document width (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 "components/dom_distiller/core/dom_distiller_service.h" 5 #include "components/dom_distiller/core/dom_distiller_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 GURL url("http://www.example.com/p1"); 119 GURL url("http://www.example.com/p1");
120 std::string entry_id("id0"); 120 std::string entry_id("id0");
121 ArticleEntry entry; 121 ArticleEntry entry;
122 entry.set_entry_id(entry_id); 122 entry.set_entry_id(entry_id);
123 entry.add_pages()->set_url(url.spec()); 123 entry.add_pages()->set_url(url.spec());
124 124
125 store_->AddEntry(entry); 125 store_->AddEntry(entry);
126 126
127 FakeViewRequestDelegate viewer_delegate; 127 FakeViewRequestDelegate viewer_delegate;
128 scoped_ptr<ViewerHandle> handle = service_->ViewEntry( 128 scoped_ptr<ViewerHandle> handle = service_->ViewEntry(
129 &viewer_delegate, service_->CreateDefaultDistillerPage(), entry_id); 129 &viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()),
130 entry_id);
130 131
131 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 132 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
132 133
133 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle(); 134 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
134 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get())); 135 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
135 136
136 RunDistillerCallback(distiller, proto.Pass()); 137 RunDistillerCallback(distiller, proto.Pass());
137 } 138 }
138 139
139 TEST_F(DomDistillerServiceTest, TestViewUrl) { 140 TEST_F(DomDistillerServiceTest, TestViewUrl) {
140 FakeDistiller* distiller = new FakeDistiller(false); 141 FakeDistiller* distiller = new FakeDistiller(false);
141 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 142 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
142 .WillOnce(Return(distiller)); 143 .WillOnce(Return(distiller));
143 144
144 FakeViewRequestDelegate viewer_delegate; 145 FakeViewRequestDelegate viewer_delegate;
145 GURL url("http://www.example.com/p1"); 146 GURL url("http://www.example.com/p1");
146 scoped_ptr<ViewerHandle> handle = service_->ViewUrl( 147 scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
147 &viewer_delegate, service_->CreateDefaultDistillerPage(), url); 148 &viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
148 149
149 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 150 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
150 EXPECT_EQ(url, distiller->GetUrl()); 151 EXPECT_EQ(url, distiller->GetUrl());
151 152
152 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle(); 153 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
153 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get())); 154 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
154 155
155 RunDistillerCallback(distiller, proto.Pass()); 156 RunDistillerCallback(distiller, proto.Pass());
156 } 157 }
157 158
158 TEST_F(DomDistillerServiceTest, TestMultipleViewUrl) { 159 TEST_F(DomDistillerServiceTest, TestMultipleViewUrl) {
159 FakeDistiller* distiller = new FakeDistiller(false); 160 FakeDistiller* distiller = new FakeDistiller(false);
160 FakeDistiller* distiller2 = new FakeDistiller(false); 161 FakeDistiller* distiller2 = new FakeDistiller(false);
161 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 162 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
162 .WillOnce(Return(distiller)) 163 .WillOnce(Return(distiller))
163 .WillOnce(Return(distiller2)); 164 .WillOnce(Return(distiller2));
164 165
165 FakeViewRequestDelegate viewer_delegate; 166 FakeViewRequestDelegate viewer_delegate;
166 FakeViewRequestDelegate viewer_delegate2; 167 FakeViewRequestDelegate viewer_delegate2;
167 168
168 GURL url("http://www.example.com/p1"); 169 GURL url("http://www.example.com/p1");
169 GURL url2("http://www.example.com/a/p1"); 170 GURL url2("http://www.example.com/a/p1");
170 171
171 scoped_ptr<ViewerHandle> handle = service_->ViewUrl( 172 scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
172 &viewer_delegate, service_->CreateDefaultDistillerPage(), url); 173 &viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
173 scoped_ptr<ViewerHandle> handle2 = service_->ViewUrl( 174 scoped_ptr<ViewerHandle> handle2 = service_->ViewUrl(
174 &viewer_delegate2, service_->CreateDefaultDistillerPage(), url2); 175 &viewer_delegate2, service_->CreateDefaultDistillerPage(gfx::Size()),
176 url2);
175 177
176 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 178 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
177 EXPECT_EQ(url, distiller->GetUrl()); 179 EXPECT_EQ(url, distiller->GetUrl());
178 180
179 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle(); 181 scoped_ptr<DistilledArticleProto> proto = CreateDefaultArticle();
180 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get())); 182 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
181 183
182 RunDistillerCallback(distiller, proto.Pass()); 184 RunDistillerCallback(distiller, proto.Pass());
183 185
184 ASSERT_FALSE(distiller2->GetArticleCallback().is_null()); 186 ASSERT_FALSE(distiller2->GetArticleCallback().is_null());
(...skipping 10 matching lines...) Expand all
195 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 197 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
196 .WillOnce(Return(distiller)); 198 .WillOnce(Return(distiller));
197 199
198 bool distiller_destroyed = false; 200 bool distiller_destroyed = false;
199 EXPECT_CALL(*distiller, Die()) 201 EXPECT_CALL(*distiller, Die())
200 .WillOnce(testing::Assign(&distiller_destroyed, true)); 202 .WillOnce(testing::Assign(&distiller_destroyed, true));
201 203
202 FakeViewRequestDelegate viewer_delegate; 204 FakeViewRequestDelegate viewer_delegate;
203 GURL url("http://www.example.com/p1"); 205 GURL url("http://www.example.com/p1");
204 scoped_ptr<ViewerHandle> handle = service_->ViewUrl( 206 scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
205 &viewer_delegate, service_->CreateDefaultDistillerPage(), url); 207 &viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
206 208
207 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 209 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
208 EXPECT_EQ(url, distiller->GetUrl()); 210 EXPECT_EQ(url, distiller->GetUrl());
209 211
210 EXPECT_CALL(viewer_delegate, OnArticleReady(_)).Times(0); 212 EXPECT_CALL(viewer_delegate, OnArticleReady(_)).Times(0);
211 213
212 EXPECT_FALSE(distiller_destroyed); 214 EXPECT_FALSE(distiller_destroyed);
213 215
214 handle.reset(); 216 handle.reset();
215 base::RunLoop().RunUntilIdle(); 217 base::RunLoop().RunUntilIdle();
216 EXPECT_TRUE(distiller_destroyed); 218 EXPECT_TRUE(distiller_destroyed);
217 } 219 }
218 220
219 TEST_F(DomDistillerServiceTest, TestViewUrlDoesNotAddEntry) { 221 TEST_F(DomDistillerServiceTest, TestViewUrlDoesNotAddEntry) {
220 FakeDistiller* distiller = new FakeDistiller(false); 222 FakeDistiller* distiller = new FakeDistiller(false);
221 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 223 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
222 .WillOnce(Return(distiller)); 224 .WillOnce(Return(distiller));
223 225
224 FakeViewRequestDelegate viewer_delegate; 226 FakeViewRequestDelegate viewer_delegate;
225 GURL url("http://www.example.com/p1"); 227 GURL url("http://www.example.com/p1");
226 scoped_ptr<ViewerHandle> handle = service_->ViewUrl( 228 scoped_ptr<ViewerHandle> handle = service_->ViewUrl(
227 &viewer_delegate, service_->CreateDefaultDistillerPage(), url); 229 &viewer_delegate, service_->CreateDefaultDistillerPage(gfx::Size()), url);
228 230
229 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec()); 231 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
230 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get())); 232 EXPECT_CALL(viewer_delegate, OnArticleReady(proto.get()));
231 233
232 RunDistillerCallback(distiller, proto.Pass()); 234 RunDistillerCallback(distiller, proto.Pass());
233 base::RunLoop().RunUntilIdle(); 235 base::RunLoop().RunUntilIdle();
234 // The entry should not be added to the store. 236 // The entry should not be added to the store.
235 EXPECT_EQ(0u, store_->GetEntries().size()); 237 EXPECT_EQ(0u, store_->GetEntries().size());
236 } 238 }
237 239
238 TEST_F(DomDistillerServiceTest, TestAddAndRemoveEntry) { 240 TEST_F(DomDistillerServiceTest, TestAddAndRemoveEntry) {
239 FakeDistiller* distiller = new FakeDistiller(false); 241 FakeDistiller* distiller = new FakeDistiller(false);
240 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 242 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
241 .WillOnce(Return(distiller)); 243 .WillOnce(Return(distiller));
242 244
243 GURL url("http://www.example.com/p1"); 245 GURL url("http://www.example.com/p1");
244 246
245 MockArticleAvailableCallback article_cb; 247 MockArticleAvailableCallback article_cb;
246 EXPECT_CALL(article_cb, DistillationCompleted(true)); 248 EXPECT_CALL(article_cb, DistillationCompleted(true));
247 249
248 std::string entry_id = 250 std::string entry_id =
249 service_->AddToList(url, service_->CreateDefaultDistillerPage().Pass(), 251 service_->AddToList(url,
250 ArticleCallback(&article_cb)); 252 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
253 ArticleCallback(&article_cb));
251 254
252 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 255 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
253 EXPECT_EQ(url, distiller->GetUrl()); 256 EXPECT_EQ(url, distiller->GetUrl());
254 257
255 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec()); 258 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
256 RunDistillerCallback(distiller, proto.Pass()); 259 RunDistillerCallback(distiller, proto.Pass());
257 260
258 ArticleEntry entry; 261 ArticleEntry entry;
259 EXPECT_TRUE(store_->GetEntryByUrl(url, &entry)); 262 EXPECT_TRUE(store_->GetEntryByUrl(url, &entry));
260 EXPECT_EQ(entry.entry_id(), entry_id); 263 EXPECT_EQ(entry.entry_id(), entry_id);
261 EXPECT_EQ(1u, store_->GetEntries().size()); 264 EXPECT_EQ(1u, store_->GetEntries().size());
262 service_->RemoveEntry(entry_id); 265 service_->RemoveEntry(entry_id);
263 base::RunLoop().RunUntilIdle(); 266 base::RunLoop().RunUntilIdle();
264 EXPECT_EQ(0u, store_->GetEntries().size()); 267 EXPECT_EQ(0u, store_->GetEntries().size());
265 } 268 }
266 269
267 TEST_F(DomDistillerServiceTest, TestCancellation) { 270 TEST_F(DomDistillerServiceTest, TestCancellation) {
268 FakeDistiller* distiller = new FakeDistiller(false); 271 FakeDistiller* distiller = new FakeDistiller(false);
269 MockDistillerObserver observer; 272 MockDistillerObserver observer;
270 service_->AddObserver(&observer); 273 service_->AddObserver(&observer);
271 274
272 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 275 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
273 .WillOnce(Return(distiller)); 276 .WillOnce(Return(distiller));
274 277
275 MockArticleAvailableCallback article_cb; 278 MockArticleAvailableCallback article_cb;
276 EXPECT_CALL(article_cb, DistillationCompleted(false)); 279 EXPECT_CALL(article_cb, DistillationCompleted(false));
277 280
278 GURL url("http://www.example.com/p1"); 281 GURL url("http://www.example.com/p1");
279 std::string entry_id = 282 std::string entry_id =
280 service_->AddToList(url, service_->CreateDefaultDistillerPage().Pass(), 283 service_->AddToList(url,
281 ArticleCallback(&article_cb)); 284 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
285 ArticleCallback(&article_cb));
282 286
283 // Remove entry will cause the |article_cb| to be called with false value. 287 // Remove entry will cause the |article_cb| to be called with false value.
284 service_->RemoveEntry(entry_id); 288 service_->RemoveEntry(entry_id);
285 base::RunLoop().RunUntilIdle(); 289 base::RunLoop().RunUntilIdle();
286 } 290 }
287 291
288 TEST_F(DomDistillerServiceTest, TestMultipleObservers) { 292 TEST_F(DomDistillerServiceTest, TestMultipleObservers) {
289 FakeDistiller* distiller = new FakeDistiller(false); 293 FakeDistiller* distiller = new FakeDistiller(false);
290 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 294 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
291 .WillOnce(Return(distiller)); 295 .WillOnce(Return(distiller));
292 296
293 const int kObserverCount = 5; 297 const int kObserverCount = 5;
294 MockDistillerObserver observers[kObserverCount]; 298 MockDistillerObserver observers[kObserverCount];
295 for (int i = 0; i < kObserverCount; ++i) { 299 for (int i = 0; i < kObserverCount; ++i) {
296 service_->AddObserver(&observers[i]); 300 service_->AddObserver(&observers[i]);
297 } 301 }
298 302
299 DomDistillerService::ArticleAvailableCallback article_cb; 303 DomDistillerService::ArticleAvailableCallback article_cb;
300 GURL url("http://www.example.com/p1"); 304 GURL url("http://www.example.com/p1");
301 std::string entry_id = service_->AddToList( 305 std::string entry_id = service_->AddToList(
302 url, service_->CreateDefaultDistillerPage().Pass(), article_cb); 306 url, service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
307 article_cb);
303 308
304 // Distillation should notify all observers that article is added. 309 // Distillation should notify all observers that article is added.
305 std::vector<DomDistillerObserver::ArticleUpdate> expected_updates; 310 std::vector<DomDistillerObserver::ArticleUpdate> expected_updates;
306 DomDistillerObserver::ArticleUpdate update; 311 DomDistillerObserver::ArticleUpdate update;
307 update.entry_id = entry_id; 312 update.entry_id = entry_id;
308 update.update_type = DomDistillerObserver::ArticleUpdate::ADD; 313 update.update_type = DomDistillerObserver::ArticleUpdate::ADD;
309 expected_updates.push_back(update); 314 expected_updates.push_back(update);
310 315
311 for (int i = 0; i < kObserverCount; ++i) { 316 for (int i = 0; i < kObserverCount; ++i) {
312 EXPECT_CALL(observers[i], ArticleEntriesUpdated( 317 EXPECT_CALL(observers[i], ArticleEntriesUpdated(
(...skipping 19 matching lines...) Expand all
332 TEST_F(DomDistillerServiceTest, TestMultipleCallbacks) { 337 TEST_F(DomDistillerServiceTest, TestMultipleCallbacks) {
333 FakeDistiller* distiller = new FakeDistiller(false); 338 FakeDistiller* distiller = new FakeDistiller(false);
334 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 339 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
335 .WillOnce(Return(distiller)); 340 .WillOnce(Return(distiller));
336 341
337 const int kClientsCount = 5; 342 const int kClientsCount = 5;
338 MockArticleAvailableCallback article_cb[kClientsCount]; 343 MockArticleAvailableCallback article_cb[kClientsCount];
339 // Adding a URL and then distilling calls all clients. 344 // Adding a URL and then distilling calls all clients.
340 GURL url("http://www.example.com/p1"); 345 GURL url("http://www.example.com/p1");
341 const std::string entry_id = 346 const std::string entry_id =
342 service_->AddToList(url, service_->CreateDefaultDistillerPage().Pass(), 347 service_->AddToList(url,
343 ArticleCallback(&article_cb[0])); 348 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
349 ArticleCallback(&article_cb[0]));
344 EXPECT_CALL(article_cb[0], DistillationCompleted(true)); 350 EXPECT_CALL(article_cb[0], DistillationCompleted(true));
345 351
346 for (int i = 1; i < kClientsCount; ++i) { 352 for (int i = 1; i < kClientsCount; ++i) {
347 EXPECT_EQ(entry_id, service_->AddToList( 353 EXPECT_EQ(entry_id,
348 url, service_->CreateDefaultDistillerPage().Pass(), 354 service_->AddToList(
349 ArticleCallback(&article_cb[i]))); 355 url,
356 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
357 ArticleCallback(&article_cb[i])));
350 EXPECT_CALL(article_cb[i], DistillationCompleted(true)); 358 EXPECT_CALL(article_cb[i], DistillationCompleted(true));
351 } 359 }
352 360
353 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec()); 361 scoped_ptr<DistilledArticleProto> proto = CreateArticleWithURL(url.spec());
354 RunDistillerCallback(distiller, proto.Pass()); 362 RunDistillerCallback(distiller, proto.Pass());
355 363
356 // Add the same url again, all callbacks should be called with true. 364 // Add the same url again, all callbacks should be called with true.
357 for (int i = 0; i < kClientsCount; ++i) { 365 for (int i = 0; i < kClientsCount; ++i) {
358 EXPECT_CALL(article_cb[i], DistillationCompleted(true)); 366 EXPECT_CALL(article_cb[i], DistillationCompleted(true));
359 EXPECT_EQ(entry_id, service_->AddToList( 367 EXPECT_EQ(entry_id,
360 url, service_->CreateDefaultDistillerPage().Pass(), 368 service_->AddToList(
361 ArticleCallback(&article_cb[i]))); 369 url,
370 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
371 ArticleCallback(&article_cb[i])));
362 } 372 }
363 373
364 base::RunLoop().RunUntilIdle(); 374 base::RunLoop().RunUntilIdle();
365 } 375 }
366 376
367 TEST_F(DomDistillerServiceTest, TestMultipleCallbacksOnRemove) { 377 TEST_F(DomDistillerServiceTest, TestMultipleCallbacksOnRemove) {
368 FakeDistiller* distiller = new FakeDistiller(false); 378 FakeDistiller* distiller = new FakeDistiller(false);
369 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 379 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
370 .WillOnce(Return(distiller)); 380 .WillOnce(Return(distiller));
371 381
372 const int kClientsCount = 5; 382 const int kClientsCount = 5;
373 MockArticleAvailableCallback article_cb[kClientsCount]; 383 MockArticleAvailableCallback article_cb[kClientsCount];
374 // Adding a URL and remove the entry before distillation. Callback should be 384 // Adding a URL and remove the entry before distillation. Callback should be
375 // called with false. 385 // called with false.
376 GURL url("http://www.example.com/p1"); 386 GURL url("http://www.example.com/p1");
377 const std::string entry_id = 387 const std::string entry_id =
378 service_->AddToList(url, service_->CreateDefaultDistillerPage().Pass(), 388 service_->AddToList(url,
379 ArticleCallback(&article_cb[0])); 389 service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
390 ArticleCallback(&article_cb[0]));
380 391
381 EXPECT_CALL(article_cb[0], DistillationCompleted(false)); 392 EXPECT_CALL(article_cb[0], DistillationCompleted(false));
382 for (int i = 1; i < kClientsCount; ++i) { 393 for (int i = 1; i < kClientsCount; ++i) {
383 EXPECT_EQ(entry_id, service_->AddToList( 394 EXPECT_EQ(entry_id,
384 url, service_->CreateDefaultDistillerPage().Pass(), 395 service_->AddToList(
385 ArticleCallback(&article_cb[i]))); 396 url, service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
397 ArticleCallback(&article_cb[i])));
386 EXPECT_CALL(article_cb[i], DistillationCompleted(false)); 398 EXPECT_CALL(article_cb[i], DistillationCompleted(false));
387 } 399 }
388 400
389 service_->RemoveEntry(entry_id); 401 service_->RemoveEntry(entry_id);
390 base::RunLoop().RunUntilIdle(); 402 base::RunLoop().RunUntilIdle();
391 } 403 }
392 404
393 TEST_F(DomDistillerServiceTest, TestMultiplePageArticle) { 405 TEST_F(DomDistillerServiceTest, TestMultiplePageArticle) {
394 FakeDistiller* distiller = new FakeDistiller(false); 406 FakeDistiller* distiller = new FakeDistiller(false);
395 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) 407 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl())
396 .WillOnce(Return(distiller)); 408 .WillOnce(Return(distiller));
397 409
398 const int kPageCount = 8; 410 const int kPageCount = 8;
399 411
400 std::string base_url("http://www.example.com/p"); 412 std::string base_url("http://www.example.com/p");
401 GURL pages_url[kPageCount]; 413 GURL pages_url[kPageCount];
402 for (int page_num = 0; page_num < kPageCount; ++page_num) { 414 for (int page_num = 0; page_num < kPageCount; ++page_num) {
403 pages_url[page_num] = GURL(base_url + base::IntToString(page_num)); 415 pages_url[page_num] = GURL(base_url + base::IntToString(page_num));
404 } 416 }
405 417
406 MockArticleAvailableCallback article_cb; 418 MockArticleAvailableCallback article_cb;
407 EXPECT_CALL(article_cb, DistillationCompleted(true)); 419 EXPECT_CALL(article_cb, DistillationCompleted(true));
408 420
409 std::string entry_id = service_->AddToList( 421 std::string entry_id = service_->AddToList(
410 pages_url[0], service_->CreateDefaultDistillerPage().Pass(), 422 pages_url[0], service_->CreateDefaultDistillerPage(gfx::Size()).Pass(),
411 ArticleCallback(&article_cb)); 423 ArticleCallback(&article_cb));
412 424
413 ArticleEntry entry; 425 ArticleEntry entry;
414 ASSERT_FALSE(distiller->GetArticleCallback().is_null()); 426 ASSERT_FALSE(distiller->GetArticleCallback().is_null());
415 EXPECT_EQ(pages_url[0], distiller->GetUrl()); 427 EXPECT_EQ(pages_url[0], distiller->GetUrl());
416 428
417 // Create the article with pages to pass to the distiller. 429 // Create the article with pages to pass to the distiller.
418 scoped_ptr<DistilledArticleProto> proto = 430 scoped_ptr<DistilledArticleProto> proto =
419 CreateArticleWithURL(pages_url[0].spec()); 431 CreateArticleWithURL(pages_url[0].spec());
420 for (int page_num = 1; page_num < kPageCount; ++page_num) { 432 for (int page_num = 1; page_num < kPageCount; ++page_num) {
(...skipping 18 matching lines...) Expand all
439 EXPECT_TRUE(store_->GetEntryByUrl(pages_url[page_num], &entry)); 451 EXPECT_TRUE(store_->GetEntryByUrl(pages_url[page_num], &entry));
440 } 452 }
441 453
442 service_->RemoveEntry(entry_id); 454 service_->RemoveEntry(entry_id);
443 base::RunLoop().RunUntilIdle(); 455 base::RunLoop().RunUntilIdle();
444 EXPECT_EQ(0u, store_->GetEntries().size()); 456 EXPECT_EQ(0u, store_->GetEntries().size());
445 } 457 }
446 458
447 } // namespace test 459 } // namespace test
448 } // namespace dom_distiller 460 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698