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

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

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 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/distiller.h" 5 #include "components/dom_distiller/core/distiller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
8 #include <algorithm> 9 #include <algorithm>
9 #include <map> 10 #include <map>
11 #include <memory>
10 #include <string> 12 #include <string>
11 #include <utility> 13 #include <utility>
12 #include <vector> 14 #include <vector>
13 15
14 #include "base/bind.h" 16 #include "base/bind.h"
15 #include "base/bind_helpers.h" 17 #include "base/bind_helpers.h"
16 #include "base/location.h" 18 #include "base/location.h"
17 #include "base/macros.h" 19 #include "base/macros.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
23 #include "base/values.h" 24 #include "base/values.h"
24 #include "components/dom_distiller/core/article_distillation_update.h" 25 #include "components/dom_distiller/core/article_distillation_update.h"
25 #include "components/dom_distiller/core/distiller_page.h" 26 #include "components/dom_distiller/core/distiller_page.h"
26 #include "components/dom_distiller/core/fake_distiller_page.h" 27 #include "components/dom_distiller/core/fake_distiller_page.h"
27 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 28 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
28 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 29 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
(...skipping 22 matching lines...) Expand all
51 const char* kImageURLs[kTotalImages] = {"http://a.com/img1.jpg", 52 const char* kImageURLs[kTotalImages] = {"http://a.com/img1.jpg",
52 "http://a.com/img2.jpg", 53 "http://a.com/img2.jpg",
53 "./bad_url_should_fail"}; 54 "./bad_url_should_fail"};
54 const char* kImageData[kTotalImages] = {"abcde", "12345", "VWXYZ"}; 55 const char* kImageData[kTotalImages] = {"abcde", "12345", "VWXYZ"};
55 const char kDebugLog[] = "Debug Log"; 56 const char kDebugLog[] = "Debug Log";
56 57
57 const string GetImageName(int page_num, int image_num) { 58 const string GetImageName(int page_num, int image_num) {
58 return base::IntToString(page_num) + "_" + base::IntToString(image_num); 59 return base::IntToString(page_num) + "_" + base::IntToString(image_num);
59 } 60 }
60 61
61 scoped_ptr<base::Value> CreateDistilledValueReturnedFromJS( 62 std::unique_ptr<base::Value> CreateDistilledValueReturnedFromJS(
62 const string& title, 63 const string& title,
63 const string& content, 64 const string& content,
64 const vector<int>& image_indices, 65 const vector<int>& image_indices,
65 const string& next_page_url, 66 const string& next_page_url,
66 const string& prev_page_url = "") { 67 const string& prev_page_url = "") {
67 DomDistillerResult result; 68 DomDistillerResult result;
68 result.set_title(title); 69 result.set_title(title);
69 result.mutable_distilled_content()->set_html(content); 70 result.mutable_distilled_content()->set_html(content);
70 result.mutable_pagination_info()->set_next_page(next_page_url); 71 result.mutable_pagination_info()->set_next_page(next_page_url);
71 result.mutable_pagination_info()->set_prev_page(prev_page_url); 72 result.mutable_pagination_info()->set_prev_page(prev_page_url);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 string GenerateNextPageUrl(const std::string& url_prefix, size_t page_num, 151 string GenerateNextPageUrl(const std::string& url_prefix, size_t page_num,
151 size_t pages_size) { 152 size_t pages_size) {
152 return page_num + 1 < pages_size ? 153 return page_num + 1 < pages_size ?
153 url_prefix + base::SizeTToString(page_num + 1) : ""; 154 url_prefix + base::SizeTToString(page_num + 1) : "";
154 } 155 }
155 156
156 string GeneratePrevPageUrl(const std::string& url_prefix, size_t page_num) { 157 string GeneratePrevPageUrl(const std::string& url_prefix, size_t page_num) {
157 return page_num > 0 ? url_prefix + base::SizeTToString(page_num - 1) : ""; 158 return page_num > 0 ? url_prefix + base::SizeTToString(page_num - 1) : "";
158 } 159 }
159 160
160 scoped_ptr<MultipageDistillerData> CreateMultipageDistillerDataWithoutImages( 161 std::unique_ptr<MultipageDistillerData>
161 size_t pages_size) { 162 CreateMultipageDistillerDataWithoutImages(size_t pages_size) {
162 scoped_ptr<MultipageDistillerData> result(new MultipageDistillerData()); 163 std::unique_ptr<MultipageDistillerData> result(new MultipageDistillerData());
163 string url_prefix = kURL; 164 string url_prefix = kURL;
164 for (size_t page_num = 0; page_num < pages_size; ++page_num) { 165 for (size_t page_num = 0; page_num < pages_size; ++page_num) {
165 result->page_urls.push_back(url_prefix + base::SizeTToString(page_num)); 166 result->page_urls.push_back(url_prefix + base::SizeTToString(page_num));
166 result->content.push_back("Content for page:" + 167 result->content.push_back("Content for page:" +
167 base::SizeTToString(page_num)); 168 base::SizeTToString(page_num));
168 result->image_ids.push_back(vector<int>()); 169 result->image_ids.push_back(vector<int>());
169 string next_page_url = 170 string next_page_url =
170 GenerateNextPageUrl(url_prefix, page_num, pages_size); 171 GenerateNextPageUrl(url_prefix, page_num, pages_size);
171 string prev_page_url = 172 string prev_page_url =
172 GeneratePrevPageUrl(url_prefix, page_num); 173 GeneratePrevPageUrl(url_prefix, page_num);
173 scoped_ptr<base::Value> distilled_value = 174 std::unique_ptr<base::Value> distilled_value =
174 CreateDistilledValueReturnedFromJS(kTitle, 175 CreateDistilledValueReturnedFromJS(kTitle, result->content[page_num],
175 result->content[page_num],
176 result->image_ids[page_num], 176 result->image_ids[page_num],
177 next_page_url, 177 next_page_url, prev_page_url);
178 prev_page_url);
179 result->distilled_values.push_back(distilled_value.release()); 178 result->distilled_values.push_back(distilled_value.release());
180 } 179 }
181 return result; 180 return result;
182 } 181 }
183 182
184 void VerifyArticleProtoMatchesMultipageData( 183 void VerifyArticleProtoMatchesMultipageData(
185 const dom_distiller::DistilledArticleProto* article_proto, 184 const dom_distiller::DistilledArticleProto* article_proto,
186 const MultipageDistillerData* distiller_data, 185 const MultipageDistillerData* distiller_data,
187 size_t distilled_pages_size, 186 size_t distilled_pages_size,
188 size_t total_pages_size) { 187 size_t total_pages_size) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 MockDistillerURLFetcherFactory() : DistillerURLFetcherFactory(NULL) {} 267 MockDistillerURLFetcherFactory() : DistillerURLFetcherFactory(NULL) {}
269 virtual ~MockDistillerURLFetcherFactory() {} 268 virtual ~MockDistillerURLFetcherFactory() {}
270 269
271 MOCK_CONST_METHOD0(CreateDistillerURLFetcher, DistillerURLFetcher*()); 270 MOCK_CONST_METHOD0(CreateDistillerURLFetcher, DistillerURLFetcher*());
272 }; 271 };
273 272
274 class DistillerTest : public testing::Test { 273 class DistillerTest : public testing::Test {
275 public: 274 public:
276 ~DistillerTest() override {} 275 ~DistillerTest() override {}
277 276
278 void OnDistillArticleDone(scoped_ptr<DistilledArticleProto> proto) { 277 void OnDistillArticleDone(std::unique_ptr<DistilledArticleProto> proto) {
279 article_proto_ = std::move(proto); 278 article_proto_ = std::move(proto);
280 } 279 }
281 280
282 void OnDistillArticleUpdate(const ArticleDistillationUpdate& article_update) { 281 void OnDistillArticleUpdate(const ArticleDistillationUpdate& article_update) {
283 in_sequence_updates_.push_back(article_update); 282 in_sequence_updates_.push_back(article_update);
284 } 283 }
285 284
286 void DistillPage(const std::string& url, 285 void DistillPage(const std::string& url,
287 scoped_ptr<DistillerPage> distiller_page) { 286 std::unique_ptr<DistillerPage> distiller_page) {
288 distiller_->DistillPage(GURL(url), std::move(distiller_page), 287 distiller_->DistillPage(GURL(url), std::move(distiller_page),
289 base::Bind(&DistillerTest::OnDistillArticleDone, 288 base::Bind(&DistillerTest::OnDistillArticleDone,
290 base::Unretained(this)), 289 base::Unretained(this)),
291 base::Bind(&DistillerTest::OnDistillArticleUpdate, 290 base::Bind(&DistillerTest::OnDistillArticleUpdate,
292 base::Unretained(this))); 291 base::Unretained(this)));
293 } 292 }
294 293
295 protected: 294 protected:
296 scoped_ptr<DistillerImpl> distiller_; 295 std::unique_ptr<DistillerImpl> distiller_;
297 scoped_ptr<DistilledArticleProto> article_proto_; 296 std::unique_ptr<DistilledArticleProto> article_proto_;
298 std::vector<ArticleDistillationUpdate> in_sequence_updates_; 297 std::vector<ArticleDistillationUpdate> in_sequence_updates_;
299 MockDistillerPageFactory page_factory_; 298 MockDistillerPageFactory page_factory_;
300 TestDistillerURLFetcherFactory url_fetcher_factory_; 299 TestDistillerURLFetcherFactory url_fetcher_factory_;
301 }; 300 };
302 301
303 ACTION_P3(DistillerPageOnDistillationDone, distiller_page, url, result) { 302 ACTION_P3(DistillerPageOnDistillationDone, distiller_page, url, result) {
304 distiller_page->OnDistillationDone(url, result); 303 distiller_page->OnDistillationDone(url, result);
305 } 304 }
306 305
307 scoped_ptr<DistillerPage> CreateMockDistillerPage(const base::Value* result, 306 std::unique_ptr<DistillerPage> CreateMockDistillerPage(
308 const GURL& url) { 307 const base::Value* result,
308 const GURL& url) {
309 MockDistillerPage* distiller_page = new MockDistillerPage(); 309 MockDistillerPage* distiller_page = new MockDistillerPage();
310 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _)) 310 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _))
311 .WillOnce(DistillerPageOnDistillationDone(distiller_page, url, result)); 311 .WillOnce(DistillerPageOnDistillationDone(distiller_page, url, result));
312 return scoped_ptr<DistillerPage>(distiller_page); 312 return std::unique_ptr<DistillerPage>(distiller_page);
313 } 313 }
314 314
315 scoped_ptr<DistillerPage> CreateMockDistillerPageWithPendingJSCallback( 315 std::unique_ptr<DistillerPage> CreateMockDistillerPageWithPendingJSCallback(
316 MockDistillerPage** distiller_page_ptr, 316 MockDistillerPage** distiller_page_ptr,
317 const GURL& url) { 317 const GURL& url) {
318 MockDistillerPage* distiller_page = new MockDistillerPage(); 318 MockDistillerPage* distiller_page = new MockDistillerPage();
319 *distiller_page_ptr = distiller_page; 319 *distiller_page_ptr = distiller_page;
320 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _)); 320 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _));
321 return scoped_ptr<DistillerPage>(distiller_page); 321 return std::unique_ptr<DistillerPage>(distiller_page);
322 } 322 }
323 323
324 scoped_ptr<DistillerPage> CreateMockDistillerPages( 324 std::unique_ptr<DistillerPage> CreateMockDistillerPages(
325 MultipageDistillerData* distiller_data, 325 MultipageDistillerData* distiller_data,
326 size_t pages_size, 326 size_t pages_size,
327 int start_page_num) { 327 int start_page_num) {
328 MockDistillerPage* distiller_page = new MockDistillerPage(); 328 MockDistillerPage* distiller_page = new MockDistillerPage();
329 { 329 {
330 testing::InSequence s; 330 testing::InSequence s;
331 vector<int> page_nums = GetPagesInSequence(start_page_num, pages_size); 331 vector<int> page_nums = GetPagesInSequence(start_page_num, pages_size);
332 for (size_t page_num = 0; page_num < pages_size; ++page_num) { 332 for (size_t page_num = 0; page_num < pages_size; ++page_num) {
333 int page = page_nums[page_num]; 333 int page = page_nums[page_num];
334 GURL url = GURL(distiller_data->page_urls[page]); 334 GURL url = GURL(distiller_data->page_urls[page]);
335 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _)) 335 EXPECT_CALL(*distiller_page, DistillPageImpl(url, _))
336 .WillOnce(DistillerPageOnDistillationDone( 336 .WillOnce(DistillerPageOnDistillationDone(
337 distiller_page, url, distiller_data->distilled_values[page])); 337 distiller_page, url, distiller_data->distilled_values[page]));
338 } 338 }
339 } 339 }
340 return scoped_ptr<DistillerPage>(distiller_page); 340 return std::unique_ptr<DistillerPage>(distiller_page);
341 } 341 }
342 342
343 TEST_F(DistillerTest, DistillPage) { 343 TEST_F(DistillerTest, DistillPage) {
344 base::MessageLoopForUI loop; 344 base::MessageLoopForUI loop;
345 scoped_ptr<base::Value> result = 345 std::unique_ptr<base::Value> result =
346 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), ""); 346 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), "");
347 distiller_.reset( 347 distiller_.reset(
348 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 348 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
349 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL))); 349 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)));
350 base::MessageLoop::current()->RunUntilIdle(); 350 base::MessageLoop::current()->RunUntilIdle();
351 EXPECT_EQ(kTitle, article_proto_->title()); 351 EXPECT_EQ(kTitle, article_proto_->title());
352 ASSERT_EQ(article_proto_->pages_size(), 1); 352 ASSERT_EQ(article_proto_->pages_size(), 1);
353 const DistilledPageProto& first_page = article_proto_->pages(0); 353 const DistilledPageProto& first_page = article_proto_->pages(0);
354 EXPECT_EQ(kContent, first_page.html()); 354 EXPECT_EQ(kContent, first_page.html());
355 EXPECT_EQ(kURL, first_page.url()); 355 EXPECT_EQ(kURL, first_page.url());
356 } 356 }
357 357
358 TEST_F(DistillerTest, DistillPageWithDebugInfo) { 358 TEST_F(DistillerTest, DistillPageWithDebugInfo) {
359 base::MessageLoopForUI loop; 359 base::MessageLoopForUI loop;
360 DomDistillerResult dd_result; 360 DomDistillerResult dd_result;
361 dd_result.mutable_debug_info()->set_log(kDebugLog); 361 dd_result.mutable_debug_info()->set_log(kDebugLog);
362 scoped_ptr<base::Value> result = 362 std::unique_ptr<base::Value> result =
363 dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result); 363 dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
364 distiller_.reset( 364 distiller_.reset(
365 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 365 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
366 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL))); 366 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)));
367 base::MessageLoop::current()->RunUntilIdle(); 367 base::MessageLoop::current()->RunUntilIdle();
368 const DistilledPageProto& first_page = article_proto_->pages(0); 368 const DistilledPageProto& first_page = article_proto_->pages(0);
369 EXPECT_EQ(kDebugLog, first_page.debug_info().log()); 369 EXPECT_EQ(kDebugLog, first_page.debug_info().log());
370 } 370 }
371 371
372 void SetTimingEntry(TimingEntry* entry, const std::string& name, double time) { 372 void SetTimingEntry(TimingEntry* entry, const std::string& name, double time) {
373 entry->set_name(name); 373 entry->set_name(name);
374 entry->set_time(time); 374 entry->set_time(time);
375 } 375 }
376 376
377 TEST_F(DistillerTest, DistillPageWithTimingInfo) { 377 TEST_F(DistillerTest, DistillPageWithTimingInfo) {
378 base::MessageLoopForUI loop; 378 base::MessageLoopForUI loop;
379 DomDistillerResult dd_result; 379 DomDistillerResult dd_result;
380 dd_result.mutable_timing_info()->set_total_time(1.0); 380 dd_result.mutable_timing_info()->set_total_time(1.0);
381 dd_result.mutable_timing_info()->set_markup_parsing_time(2.0); 381 dd_result.mutable_timing_info()->set_markup_parsing_time(2.0);
382 dd_result.mutable_timing_info()->set_document_construction_time(3.0); 382 dd_result.mutable_timing_info()->set_document_construction_time(3.0);
383 dd_result.mutable_timing_info()->set_article_processing_time(4.0); 383 dd_result.mutable_timing_info()->set_article_processing_time(4.0);
384 dd_result.mutable_timing_info()->set_formatting_time(5.0); 384 dd_result.mutable_timing_info()->set_formatting_time(5.0);
385 SetTimingEntry( 385 SetTimingEntry(
386 dd_result.mutable_timing_info()->add_other_times(), "time0", 6.0); 386 dd_result.mutable_timing_info()->add_other_times(), "time0", 6.0);
387 SetTimingEntry( 387 SetTimingEntry(
388 dd_result.mutable_timing_info()->add_other_times(), "time1", 7.0); 388 dd_result.mutable_timing_info()->add_other_times(), "time1", 7.0);
389 scoped_ptr<base::Value> result = 389 std::unique_ptr<base::Value> result =
390 dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result); 390 dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
391 distiller_.reset( 391 distiller_.reset(
392 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 392 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
393 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL))); 393 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)));
394 base::MessageLoop::current()->RunUntilIdle(); 394 base::MessageLoop::current()->RunUntilIdle();
395 const DistilledPageProto& first_page = article_proto_->pages(0); 395 const DistilledPageProto& first_page = article_proto_->pages(0);
396 std::map<std::string, double> timings; 396 std::map<std::string, double> timings;
397 for (int i = 0; i < first_page.timing_info_size(); ++i) { 397 for (int i = 0; i < first_page.timing_info_size(); ++i) {
398 DistilledPageProto::TimingInfo timing = first_page.timing_info(i); 398 DistilledPageProto::TimingInfo timing = first_page.timing_info(i);
399 timings[timing.name()] = timing.time(); 399 timings[timing.name()] = timing.time();
400 } 400 }
401 EXPECT_EQ(7u, timings.size()); 401 EXPECT_EQ(7u, timings.size());
402 EXPECT_EQ(1.0, timings["total"]); 402 EXPECT_EQ(1.0, timings["total"]);
403 EXPECT_EQ(2.0, timings["markup_parsing"]); 403 EXPECT_EQ(2.0, timings["markup_parsing"]);
404 EXPECT_EQ(3.0, timings["document_construction"]); 404 EXPECT_EQ(3.0, timings["document_construction"]);
405 EXPECT_EQ(4.0, timings["article_processing"]); 405 EXPECT_EQ(4.0, timings["article_processing"]);
406 EXPECT_EQ(5.0, timings["formatting"]); 406 EXPECT_EQ(5.0, timings["formatting"]);
407 EXPECT_EQ(6.0, timings["time0"]); 407 EXPECT_EQ(6.0, timings["time0"]);
408 EXPECT_EQ(7.0, timings["time1"]); 408 EXPECT_EQ(7.0, timings["time1"]);
409 } 409 }
410 410
411 TEST_F(DistillerTest, DistillPageWithImages) { 411 TEST_F(DistillerTest, DistillPageWithImages) {
412 base::MessageLoopForUI loop; 412 base::MessageLoopForUI loop;
413 vector<int> image_indices; 413 vector<int> image_indices;
414 image_indices.push_back(0); 414 image_indices.push_back(0);
415 image_indices.push_back(1); 415 image_indices.push_back(1);
416 image_indices.push_back(2); 416 image_indices.push_back(2);
417 scoped_ptr<base::Value> result = 417 std::unique_ptr<base::Value> result =
418 CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, ""); 418 CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, "");
419 distiller_.reset( 419 distiller_.reset(
420 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 420 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
421 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL))); 421 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)));
422 base::MessageLoop::current()->RunUntilIdle(); 422 base::MessageLoop::current()->RunUntilIdle();
423 EXPECT_EQ(kTitle, article_proto_->title()); 423 EXPECT_EQ(kTitle, article_proto_->title());
424 ASSERT_EQ(article_proto_->pages_size(), 1); 424 ASSERT_EQ(article_proto_->pages_size(), 1);
425 const DistilledPageProto& first_page = article_proto_->pages(0); 425 const DistilledPageProto& first_page = article_proto_->pages(0);
426 EXPECT_EQ(kContent, first_page.html()); 426 EXPECT_EQ(kContent, first_page.html());
427 EXPECT_EQ(kURL, first_page.url()); 427 EXPECT_EQ(kURL, first_page.url());
428 ASSERT_EQ(2, first_page.image_size()); 428 ASSERT_EQ(2, first_page.image_size());
429 EXPECT_EQ(kImageData[0], first_page.image(0).data()); 429 EXPECT_EQ(kImageData[0], first_page.image(0).data());
430 EXPECT_EQ(kImageURLs[0], first_page.image(0).url()); 430 EXPECT_EQ(kImageURLs[0], first_page.image(0).url());
431 EXPECT_EQ(GetImageName(1, 0), first_page.image(0).name()); 431 EXPECT_EQ(GetImageName(1, 0), first_page.image(0).name());
432 EXPECT_EQ(kImageData[1], first_page.image(1).data()); 432 EXPECT_EQ(kImageData[1], first_page.image(1).data());
433 EXPECT_EQ(kImageURLs[1], first_page.image(1).url()); 433 EXPECT_EQ(kImageURLs[1], first_page.image(1).url());
434 EXPECT_EQ(GetImageName(1, 1), first_page.image(1).name()); 434 EXPECT_EQ(GetImageName(1, 1), first_page.image(1).name());
435 } 435 }
436 436
437 TEST_F(DistillerTest, DistillMultiplePages) { 437 TEST_F(DistillerTest, DistillMultiplePages) {
438 base::MessageLoopForUI loop; 438 base::MessageLoopForUI loop;
439 const size_t kNumPages = 8; 439 const size_t kNumPages = 8;
440 scoped_ptr<MultipageDistillerData> distiller_data = 440 std::unique_ptr<MultipageDistillerData> distiller_data =
441 CreateMultipageDistillerDataWithoutImages(kNumPages); 441 CreateMultipageDistillerDataWithoutImages(kNumPages);
442 442
443 // Add images. 443 // Add images.
444 int next_image_number = 0; 444 int next_image_number = 0;
445 for (size_t page_num = 0; page_num < kNumPages; ++page_num) { 445 for (size_t page_num = 0; page_num < kNumPages; ++page_num) {
446 // Each page has different number of images. 446 // Each page has different number of images.
447 size_t tot_images = (page_num + kTotalImages) % (kTotalImages + 1); 447 size_t tot_images = (page_num + kTotalImages) % (kTotalImages + 1);
448 vector<int> image_indices; 448 vector<int> image_indices;
449 for (size_t img_num = 0; img_num < tot_images; img_num++) { 449 for (size_t img_num = 0; img_num < tot_images; img_num++) {
450 image_indices.push_back(next_image_number); 450 image_indices.push_back(next_image_number);
451 next_image_number = (next_image_number + 1) % kTotalImages; 451 next_image_number = (next_image_number + 1) % kTotalImages;
452 } 452 }
453 distiller_data->image_ids.push_back(image_indices); 453 distiller_data->image_ids.push_back(image_indices);
454 } 454 }
455 455
456 distiller_.reset( 456 distiller_.reset(
457 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 457 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
458 DistillPage(distiller_data->page_urls[0], 458 DistillPage(distiller_data->page_urls[0],
459 CreateMockDistillerPages(distiller_data.get(), kNumPages, 0)); 459 CreateMockDistillerPages(distiller_data.get(), kNumPages, 0));
460 base::MessageLoop::current()->RunUntilIdle(); 460 base::MessageLoop::current()->RunUntilIdle();
461 VerifyArticleProtoMatchesMultipageData( 461 VerifyArticleProtoMatchesMultipageData(
462 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages); 462 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages);
463 } 463 }
464 464
465 TEST_F(DistillerTest, DistillLinkLoop) { 465 TEST_F(DistillerTest, DistillLinkLoop) {
466 base::MessageLoopForUI loop; 466 base::MessageLoopForUI loop;
467 // Create a loop, the next page is same as the current page. This could 467 // Create a loop, the next page is same as the current page. This could
468 // happen if javascript misparses a next page link. 468 // happen if javascript misparses a next page link.
469 scoped_ptr<base::Value> result = 469 std::unique_ptr<base::Value> result =
470 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), kURL); 470 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), kURL);
471 distiller_.reset( 471 distiller_.reset(
472 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 472 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
473 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL))); 473 DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)));
474 base::MessageLoop::current()->RunUntilIdle(); 474 base::MessageLoop::current()->RunUntilIdle();
475 EXPECT_EQ(kTitle, article_proto_->title()); 475 EXPECT_EQ(kTitle, article_proto_->title());
476 EXPECT_EQ(article_proto_->pages_size(), 1); 476 EXPECT_EQ(article_proto_->pages_size(), 1);
477 } 477 }
478 478
479 TEST_F(DistillerTest, CheckMaxPageLimitExtraPage) { 479 TEST_F(DistillerTest, CheckMaxPageLimitExtraPage) {
480 base::MessageLoopForUI loop; 480 base::MessageLoopForUI loop;
481 const size_t kMaxPagesInArticle = 10; 481 const size_t kMaxPagesInArticle = 10;
482 scoped_ptr<MultipageDistillerData> distiller_data = 482 std::unique_ptr<MultipageDistillerData> distiller_data =
483 CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle); 483 CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle);
484 484
485 // Note: Next page url of the last page of article is set. So distiller will 485 // Note: Next page url of the last page of article is set. So distiller will
486 // try to do kMaxPagesInArticle + 1 calls if the max article limit does not 486 // try to do kMaxPagesInArticle + 1 calls if the max article limit does not
487 // work. 487 // work.
488 scoped_ptr<base::Value> last_page_data = 488 std::unique_ptr<base::Value> last_page_data =
489 CreateDistilledValueReturnedFromJS( 489 CreateDistilledValueReturnedFromJS(
490 kTitle, 490 kTitle, distiller_data->content[kMaxPagesInArticle - 1],
491 distiller_data->content[kMaxPagesInArticle - 1], 491 vector<int>(), "", distiller_data->page_urls[kMaxPagesInArticle - 2]);
492 vector<int>(),
493 "",
494 distiller_data->page_urls[kMaxPagesInArticle - 2]);
495 492
496 distiller_data->distilled_values.pop_back(); 493 distiller_data->distilled_values.pop_back();
497 distiller_data->distilled_values.push_back(last_page_data.release()); 494 distiller_data->distilled_values.push_back(last_page_data.release());
498 495
499 distiller_.reset( 496 distiller_.reset(
500 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 497 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
501 498
502 distiller_->SetMaxNumPagesInArticle(kMaxPagesInArticle); 499 distiller_->SetMaxNumPagesInArticle(kMaxPagesInArticle);
503 500
504 DistillPage( 501 DistillPage(
505 distiller_data->page_urls[0], 502 distiller_data->page_urls[0],
506 CreateMockDistillerPages(distiller_data.get(), kMaxPagesInArticle, 0)); 503 CreateMockDistillerPages(distiller_data.get(), kMaxPagesInArticle, 0));
507 base::MessageLoop::current()->RunUntilIdle(); 504 base::MessageLoop::current()->RunUntilIdle();
508 EXPECT_EQ(kTitle, article_proto_->title()); 505 EXPECT_EQ(kTitle, article_proto_->title());
509 EXPECT_EQ(kMaxPagesInArticle, 506 EXPECT_EQ(kMaxPagesInArticle,
510 static_cast<size_t>(article_proto_->pages_size())); 507 static_cast<size_t>(article_proto_->pages_size()));
511 } 508 }
512 509
513 TEST_F(DistillerTest, CheckMaxPageLimitExactLimit) { 510 TEST_F(DistillerTest, CheckMaxPageLimitExactLimit) {
514 base::MessageLoopForUI loop; 511 base::MessageLoopForUI loop;
515 const size_t kMaxPagesInArticle = 10; 512 const size_t kMaxPagesInArticle = 10;
516 scoped_ptr<MultipageDistillerData> distiller_data = 513 std::unique_ptr<MultipageDistillerData> distiller_data =
517 CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle); 514 CreateMultipageDistillerDataWithoutImages(kMaxPagesInArticle);
518 515
519 distiller_.reset( 516 distiller_.reset(
520 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 517 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
521 518
522 // Check if distilling an article with exactly the page limit works. 519 // Check if distilling an article with exactly the page limit works.
523 distiller_->SetMaxNumPagesInArticle(kMaxPagesInArticle); 520 distiller_->SetMaxNumPagesInArticle(kMaxPagesInArticle);
524 521
525 DistillPage( 522 DistillPage(
526 distiller_data->page_urls[0], 523 distiller_data->page_urls[0],
527 CreateMockDistillerPages(distiller_data.get(), kMaxPagesInArticle, 0)); 524 CreateMockDistillerPages(distiller_data.get(), kMaxPagesInArticle, 0));
528 base::MessageLoop::current()->RunUntilIdle(); 525 base::MessageLoop::current()->RunUntilIdle();
529 EXPECT_EQ(kTitle, article_proto_->title()); 526 EXPECT_EQ(kTitle, article_proto_->title());
530 EXPECT_EQ(kMaxPagesInArticle, 527 EXPECT_EQ(kMaxPagesInArticle,
531 static_cast<size_t>(article_proto_->pages_size())); 528 static_cast<size_t>(article_proto_->pages_size()));
532 } 529 }
533 530
534 TEST_F(DistillerTest, SinglePageDistillationFailure) { 531 TEST_F(DistillerTest, SinglePageDistillationFailure) {
535 base::MessageLoopForUI loop; 532 base::MessageLoopForUI loop;
536 // To simulate failure return a null value. 533 // To simulate failure return a null value.
537 scoped_ptr<base::Value> null_value = base::Value::CreateNullValue(); 534 std::unique_ptr<base::Value> null_value = base::Value::CreateNullValue();
538 distiller_.reset( 535 distiller_.reset(
539 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 536 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
540 DistillPage(kURL, CreateMockDistillerPage(null_value.get(), GURL(kURL))); 537 DistillPage(kURL, CreateMockDistillerPage(null_value.get(), GURL(kURL)));
541 base::MessageLoop::current()->RunUntilIdle(); 538 base::MessageLoop::current()->RunUntilIdle();
542 EXPECT_EQ("", article_proto_->title()); 539 EXPECT_EQ("", article_proto_->title());
543 EXPECT_EQ(0, article_proto_->pages_size()); 540 EXPECT_EQ(0, article_proto_->pages_size());
544 } 541 }
545 542
546 TEST_F(DistillerTest, MultiplePagesDistillationFailure) { 543 TEST_F(DistillerTest, MultiplePagesDistillationFailure) {
547 base::MessageLoopForUI loop; 544 base::MessageLoopForUI loop;
548 const size_t kNumPages = 8; 545 const size_t kNumPages = 8;
549 scoped_ptr<MultipageDistillerData> distiller_data = 546 std::unique_ptr<MultipageDistillerData> distiller_data =
550 CreateMultipageDistillerDataWithoutImages(kNumPages); 547 CreateMultipageDistillerDataWithoutImages(kNumPages);
551 548
552 // The page number of the failed page. 549 // The page number of the failed page.
553 size_t failed_page_num = 3; 550 size_t failed_page_num = 3;
554 // reset distilled data of the failed page. 551 // reset distilled data of the failed page.
555 distiller_data->distilled_values.erase( 552 distiller_data->distilled_values.erase(
556 distiller_data->distilled_values.begin() + failed_page_num); 553 distiller_data->distilled_values.begin() + failed_page_num);
557 distiller_data->distilled_values.insert( 554 distiller_data->distilled_values.insert(
558 distiller_data->distilled_values.begin() + failed_page_num, 555 distiller_data->distilled_values.begin() + failed_page_num,
559 base::Value::CreateNullValue().release()); 556 base::Value::CreateNullValue().release());
560 // Expect only calls till the failed page number. 557 // Expect only calls till the failed page number.
561 distiller_.reset( 558 distiller_.reset(
562 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 559 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
563 DistillPage( 560 DistillPage(
564 distiller_data->page_urls[0], 561 distiller_data->page_urls[0],
565 CreateMockDistillerPages(distiller_data.get(), failed_page_num + 1, 0)); 562 CreateMockDistillerPages(distiller_data.get(), failed_page_num + 1, 0));
566 base::MessageLoop::current()->RunUntilIdle(); 563 base::MessageLoop::current()->RunUntilIdle();
567 EXPECT_EQ(kTitle, article_proto_->title()); 564 EXPECT_EQ(kTitle, article_proto_->title());
568 VerifyArticleProtoMatchesMultipageData( 565 VerifyArticleProtoMatchesMultipageData(
569 article_proto_.get(), distiller_data.get(), failed_page_num, kNumPages); 566 article_proto_.get(), distiller_data.get(), failed_page_num, kNumPages);
570 } 567 }
571 568
572 TEST_F(DistillerTest, DistillPreviousPage) { 569 TEST_F(DistillerTest, DistillPreviousPage) {
573 base::MessageLoopForUI loop; 570 base::MessageLoopForUI loop;
574 const size_t kNumPages = 8; 571 const size_t kNumPages = 8;
575 572
576 // The page number of the article on which distillation starts. 573 // The page number of the article on which distillation starts.
577 int start_page_num = 3; 574 int start_page_num = 3;
578 scoped_ptr<MultipageDistillerData> distiller_data = 575 std::unique_ptr<MultipageDistillerData> distiller_data =
579 CreateMultipageDistillerDataWithoutImages(kNumPages); 576 CreateMultipageDistillerDataWithoutImages(kNumPages);
580 577
581 distiller_.reset( 578 distiller_.reset(
582 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 579 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
583 DistillPage(distiller_data->page_urls[start_page_num], 580 DistillPage(distiller_data->page_urls[start_page_num],
584 CreateMockDistillerPages(distiller_data.get(), kNumPages, 581 CreateMockDistillerPages(distiller_data.get(), kNumPages,
585 start_page_num)); 582 start_page_num));
586 base::MessageLoop::current()->RunUntilIdle(); 583 base::MessageLoop::current()->RunUntilIdle();
587 VerifyArticleProtoMatchesMultipageData( 584 VerifyArticleProtoMatchesMultipageData(
588 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages); 585 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages);
589 } 586 }
590 587
591 TEST_F(DistillerTest, IncrementalUpdates) { 588 TEST_F(DistillerTest, IncrementalUpdates) {
592 base::MessageLoopForUI loop; 589 base::MessageLoopForUI loop;
593 const size_t kNumPages = 8; 590 const size_t kNumPages = 8;
594 591
595 // The page number of the article on which distillation starts. 592 // The page number of the article on which distillation starts.
596 int start_page_num = 3; 593 int start_page_num = 3;
597 scoped_ptr<MultipageDistillerData> distiller_data = 594 std::unique_ptr<MultipageDistillerData> distiller_data =
598 CreateMultipageDistillerDataWithoutImages(kNumPages); 595 CreateMultipageDistillerDataWithoutImages(kNumPages);
599 596
600 distiller_.reset( 597 distiller_.reset(
601 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 598 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
602 DistillPage(distiller_data->page_urls[start_page_num], 599 DistillPage(distiller_data->page_urls[start_page_num],
603 CreateMockDistillerPages(distiller_data.get(), kNumPages, 600 CreateMockDistillerPages(distiller_data.get(), kNumPages,
604 start_page_num)); 601 start_page_num));
605 base::MessageLoop::current()->RunUntilIdle(); 602 base::MessageLoop::current()->RunUntilIdle();
606 EXPECT_EQ(kTitle, article_proto_->title()); 603 EXPECT_EQ(kTitle, article_proto_->title());
607 ASSERT_EQ(kNumPages, static_cast<size_t>(article_proto_->pages_size())); 604 ASSERT_EQ(kNumPages, static_cast<size_t>(article_proto_->pages_size()));
608 EXPECT_EQ(kNumPages, in_sequence_updates_.size()); 605 EXPECT_EQ(kNumPages, in_sequence_updates_.size());
609 606
610 VerifyIncrementalUpdatesMatch( 607 VerifyIncrementalUpdatesMatch(
611 distiller_data.get(), kNumPages, in_sequence_updates_, start_page_num); 608 distiller_data.get(), kNumPages, in_sequence_updates_, start_page_num);
612 } 609 }
613 610
614 TEST_F(DistillerTest, IncrementalUpdatesDoNotDeleteFinalArticle) { 611 TEST_F(DistillerTest, IncrementalUpdatesDoNotDeleteFinalArticle) {
615 base::MessageLoopForUI loop; 612 base::MessageLoopForUI loop;
616 const size_t kNumPages = 8; 613 const size_t kNumPages = 8;
617 int start_page_num = 3; 614 int start_page_num = 3;
618 scoped_ptr<MultipageDistillerData> distiller_data = 615 std::unique_ptr<MultipageDistillerData> distiller_data =
619 CreateMultipageDistillerDataWithoutImages(kNumPages); 616 CreateMultipageDistillerDataWithoutImages(kNumPages);
620 617
621 distiller_.reset( 618 distiller_.reset(
622 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 619 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
623 DistillPage(distiller_data->page_urls[start_page_num], 620 DistillPage(distiller_data->page_urls[start_page_num],
624 CreateMockDistillerPages(distiller_data.get(), kNumPages, 621 CreateMockDistillerPages(distiller_data.get(), kNumPages,
625 start_page_num)); 622 start_page_num));
626 base::MessageLoop::current()->RunUntilIdle(); 623 base::MessageLoop::current()->RunUntilIdle();
627 EXPECT_EQ(kNumPages, in_sequence_updates_.size()); 624 EXPECT_EQ(kNumPages, in_sequence_updates_.size());
628 625
629 in_sequence_updates_.clear(); 626 in_sequence_updates_.clear();
630 627
631 // Should still be able to access article and pages. 628 // Should still be able to access article and pages.
632 VerifyArticleProtoMatchesMultipageData( 629 VerifyArticleProtoMatchesMultipageData(
633 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages); 630 article_proto_.get(), distiller_data.get(), kNumPages, kNumPages);
634 } 631 }
635 632
636 TEST_F(DistillerTest, DeletingArticleDoesNotInterfereWithUpdates) { 633 TEST_F(DistillerTest, DeletingArticleDoesNotInterfereWithUpdates) {
637 base::MessageLoopForUI loop; 634 base::MessageLoopForUI loop;
638 const size_t kNumPages = 8; 635 const size_t kNumPages = 8;
639 scoped_ptr<MultipageDistillerData> distiller_data = 636 std::unique_ptr<MultipageDistillerData> distiller_data =
640 CreateMultipageDistillerDataWithoutImages(kNumPages); 637 CreateMultipageDistillerDataWithoutImages(kNumPages);
641 // The page number of the article on which distillation starts. 638 // The page number of the article on which distillation starts.
642 int start_page_num = 3; 639 int start_page_num = 3;
643 640
644 distiller_.reset( 641 distiller_.reset(
645 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 642 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
646 DistillPage(distiller_data->page_urls[start_page_num], 643 DistillPage(distiller_data->page_urls[start_page_num],
647 CreateMockDistillerPages(distiller_data.get(), kNumPages, 644 CreateMockDistillerPages(distiller_data.get(), kNumPages,
648 start_page_num)); 645 start_page_num));
649 base::MessageLoop::current()->RunUntilIdle(); 646 base::MessageLoop::current()->RunUntilIdle();
650 EXPECT_EQ(kNumPages, in_sequence_updates_.size()); 647 EXPECT_EQ(kNumPages, in_sequence_updates_.size());
651 EXPECT_EQ(kTitle, article_proto_->title()); 648 EXPECT_EQ(kTitle, article_proto_->title());
652 ASSERT_EQ(kNumPages, static_cast<size_t>(article_proto_->pages_size())); 649 ASSERT_EQ(kNumPages, static_cast<size_t>(article_proto_->pages_size()));
653 650
654 // Delete the article. 651 // Delete the article.
655 article_proto_.reset(); 652 article_proto_.reset();
656 VerifyIncrementalUpdatesMatch( 653 VerifyIncrementalUpdatesMatch(
657 distiller_data.get(), kNumPages, in_sequence_updates_, start_page_num); 654 distiller_data.get(), kNumPages, in_sequence_updates_, start_page_num);
658 } 655 }
659 656
660 TEST_F(DistillerTest, CancelWithDelayedImageFetchCallback) { 657 TEST_F(DistillerTest, CancelWithDelayedImageFetchCallback) {
661 base::MessageLoopForUI loop; 658 base::MessageLoopForUI loop;
662 vector<int> image_indices; 659 vector<int> image_indices;
663 image_indices.push_back(0); 660 image_indices.push_back(0);
664 scoped_ptr<base::Value> distilled_value = 661 std::unique_ptr<base::Value> distilled_value =
665 CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, ""); 662 CreateDistilledValueReturnedFromJS(kTitle, kContent, image_indices, "");
666 TestDistillerURLFetcher* delayed_fetcher = new TestDistillerURLFetcher(true); 663 TestDistillerURLFetcher* delayed_fetcher = new TestDistillerURLFetcher(true);
667 MockDistillerURLFetcherFactory mock_url_fetcher_factory; 664 MockDistillerURLFetcherFactory mock_url_fetcher_factory;
668 EXPECT_CALL(mock_url_fetcher_factory, CreateDistillerURLFetcher()) 665 EXPECT_CALL(mock_url_fetcher_factory, CreateDistillerURLFetcher())
669 .WillOnce(Return(delayed_fetcher)); 666 .WillOnce(Return(delayed_fetcher));
670 distiller_.reset( 667 distiller_.reset(
671 new DistillerImpl(mock_url_fetcher_factory, DomDistillerOptions())); 668 new DistillerImpl(mock_url_fetcher_factory, DomDistillerOptions()));
672 DistillPage(kURL, CreateMockDistillerPage(distilled_value.get(), GURL(kURL))); 669 DistillPage(kURL, CreateMockDistillerPage(distilled_value.get(), GURL(kURL)));
673 base::MessageLoop::current()->RunUntilIdle(); 670 base::MessageLoop::current()->RunUntilIdle();
674 671
675 // Post callback from the url fetcher and then delete the distiller. 672 // Post callback from the url fetcher and then delete the distiller.
676 delayed_fetcher->PostCallbackTask(); 673 delayed_fetcher->PostCallbackTask();
677 distiller_.reset(); 674 distiller_.reset();
678 675
679 base::MessageLoop::current()->RunUntilIdle(); 676 base::MessageLoop::current()->RunUntilIdle();
680 } 677 }
681 678
682 TEST_F(DistillerTest, CancelWithDelayedJSCallback) { 679 TEST_F(DistillerTest, CancelWithDelayedJSCallback) {
683 base::MessageLoopForUI loop; 680 base::MessageLoopForUI loop;
684 scoped_ptr<base::Value> distilled_value = 681 std::unique_ptr<base::Value> distilled_value =
685 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), ""); 682 CreateDistilledValueReturnedFromJS(kTitle, kContent, vector<int>(), "");
686 MockDistillerPage* distiller_page = NULL; 683 MockDistillerPage* distiller_page = NULL;
687 distiller_.reset( 684 distiller_.reset(
688 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions())); 685 new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
689 DistillPage(kURL, 686 DistillPage(kURL,
690 CreateMockDistillerPageWithPendingJSCallback(&distiller_page, 687 CreateMockDistillerPageWithPendingJSCallback(&distiller_page,
691 GURL(kURL))); 688 GURL(kURL)));
692 base::MessageLoop::current()->RunUntilIdle(); 689 base::MessageLoop::current()->RunUntilIdle();
693 690
694 ASSERT_TRUE(distiller_page); 691 ASSERT_TRUE(distiller_page);
695 // Post the task to execute javascript and then delete the distiller. 692 // Post the task to execute javascript and then delete the distiller.
696 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get()); 693 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get());
697 distiller_.reset(); 694 distiller_.reset();
698 695
699 base::MessageLoop::current()->RunUntilIdle(); 696 base::MessageLoop::current()->RunUntilIdle();
700 } 697 }
701 698
702 } // namespace dom_distiller 699 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_page.cc ('k') | components/dom_distiller/core/distiller_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698