OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string.h> | 5 #include <string.h> |
| 6 #include <utility> |
6 | 7 |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/guid.h" | 9 #include "base/guid.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 13 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_navigator_params.h" | 16 #include "chrome/browser/ui/browser_navigator_params.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // the article. | 139 // the article. |
139 FakeDistiller* distiller = new FakeDistiller(true); | 140 FakeDistiller* distiller = new FakeDistiller(true); |
140 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) | 141 EXPECT_CALL(*distiller_factory_, CreateDistillerImpl()) |
141 .WillOnce(testing::Return(distiller)); | 142 .WillOnce(testing::Return(distiller)); |
142 } | 143 } |
143 if (expect_distiller_page_) { | 144 if (expect_distiller_page_) { |
144 MockDistillerPage* distiller_page = new MockDistillerPage(); | 145 MockDistillerPage* distiller_page = new MockDistillerPage(); |
145 EXPECT_CALL(*distiller_page_factory_, CreateDistillerPageImpl()) | 146 EXPECT_CALL(*distiller_page_factory_, CreateDistillerPageImpl()) |
146 .WillOnce(testing::Return(distiller_page)); | 147 .WillOnce(testing::Return(distiller_page)); |
147 } | 148 } |
148 return service.Pass(); | 149 return std::move(service); |
149 } | 150 } |
150 | 151 |
151 void ViewSingleDistilledPage(const GURL& url, | 152 void ViewSingleDistilledPage(const GURL& url, |
152 const std::string& expected_mime_type); | 153 const std::string& expected_mime_type); |
153 void PrefTest(bool is_error_page); | 154 void PrefTest(bool is_error_page); |
154 // Database entries. | 155 // Database entries. |
155 static FakeDB<ArticleEntry>::EntryMap* database_model_; | 156 static FakeDB<ArticleEntry>::EntryMap* database_model_; |
156 static bool expect_distillation_; | 157 static bool expect_distillation_; |
157 static bool expect_distiller_page_; | 158 static bool expect_distiller_page_; |
158 static MockDistillerFactory* distiller_factory_; | 159 static MockDistillerFactory* distiller_factory_; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 contents, kGetLoadIndicatorClassName , &result)); | 478 contents, kGetLoadIndicatorClassName , &result)); |
478 EXPECT_EQ("hidden", result); | 479 EXPECT_EQ("hidden", result); |
479 | 480 |
480 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 481 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
481 contents, kGetContent , &result)); | 482 contents, kGetContent , &result)); |
482 EXPECT_THAT(result, HasSubstr("Page 1 content")); | 483 EXPECT_THAT(result, HasSubstr("Page 1 content")); |
483 EXPECT_THAT(result, HasSubstr("Page 2 content")); | 484 EXPECT_THAT(result, HasSubstr("Page 2 content")); |
484 } | 485 } |
485 | 486 |
486 // Complete the load. | 487 // Complete the load. |
487 distiller->RunDistillerCallback(article.Pass()); | 488 distiller->RunDistillerCallback(std::move(article)); |
488 base::RunLoop().RunUntilIdle(); | 489 base::RunLoop().RunUntilIdle(); |
489 | 490 |
490 std::string result; | 491 std::string result; |
491 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 492 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
492 contents, kGetLoadIndicatorClassName, &result)); | 493 contents, kGetLoadIndicatorClassName, &result)); |
493 EXPECT_EQ("hidden", result); | 494 EXPECT_EQ("hidden", result); |
494 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 495 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
495 contents, kGetContent , &result)); | 496 contents, kGetContent , &result)); |
496 EXPECT_THAT(result, HasSubstr("Page 1 content")); | 497 EXPECT_THAT(result, HasSubstr("Page 1 content")); |
497 EXPECT_THAT(result, HasSubstr("Page 2 content")); | 498 EXPECT_THAT(result, HasSubstr("Page 2 content")); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 EXPECT_EQ("dark serif", result); | 611 EXPECT_EQ("dark serif", result); |
611 EXPECT_EQ(kDarkToolbarThemeColor, contents->GetThemeColor()); | 612 EXPECT_EQ(kDarkToolbarThemeColor, contents->GetThemeColor()); |
612 | 613 |
613 EXPECT_TRUE(content::ExecuteScriptAndExtractString( | 614 EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
614 contents, kGetFontSize, &result)); | 615 contents, kGetFontSize, &result)); |
615 base::StringToDouble(result, &fontSize); | 616 base::StringToDouble(result, &fontSize); |
616 ASSERT_FLOAT_EQ(kScale, fontSize/oldFontSize); | 617 ASSERT_FLOAT_EQ(kScale, fontSize/oldFontSize); |
617 } | 618 } |
618 | 619 |
619 } // namespace dom_distiller | 620 } // namespace dom_distiller |
OLD | NEW |