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

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

Issue 537063002: Eliminate silently letting errors pass on pak loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ios finally works Created 6 years, 3 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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
bengr 2014/09/05 00:59:56 Do you still need this?
Avi (use Gerrit) 2014/09/05 15:17:42 Probably not. Removed.
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "components/dom_distiller/core/article_distillation_update.h" 18 #include "components/dom_distiller/core/article_distillation_update.h"
19 #include "components/dom_distiller/core/distiller.h" 19 #include "components/dom_distiller/core/distiller.h"
20 #include "components/dom_distiller/core/distiller_page.h" 20 #include "components/dom_distiller/core/distiller_page.h"
21 #include "components/dom_distiller/core/fake_distiller_page.h" 21 #include "components/dom_distiller/core/fake_distiller_page.h"
22 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 22 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
23 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 23 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
24 #include "net/url_request/url_request_context_getter.h" 24 #include "net/url_request/url_request_context_getter.h"
25 #include "testing/gmock/include/gmock/gmock.h" 25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/dom_distiller_js/dom_distiller.pb.h" 27 #include "third_party/dom_distiller_js/dom_distiller.pb.h"
28 #include "third_party/dom_distiller_js/dom_distiller_json_converter.h" 28 #include "third_party/dom_distiller_js/dom_distiller_json_converter.h"
29 #include "ui/base/resource/resource_bundle.h"
30 29
31 using std::vector; 30 using std::vector;
32 using std::string; 31 using std::string;
33 using ::testing::Invoke; 32 using ::testing::Invoke;
34 using ::testing::Return; 33 using ::testing::Return;
35 using ::testing::_; 34 using ::testing::_;
36 35
37 using dom_distiller::proto::DomDistillerOptions; 36 using dom_distiller::proto::DomDistillerOptions;
38 using dom_distiller::proto::DomDistillerResult; 37 using dom_distiller::proto::DomDistillerResult;
39 38
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const vector<int>& image_ids_for_page = distiller_data->image_ids[page_num]; 179 const vector<int>& image_ids_for_page = distiller_data->image_ids[page_num];
181 for (size_t img_num = 0; img_num < image_ids_for_page.size(); ++img_num) { 180 for (size_t img_num = 0; img_num < image_ids_for_page.size(); ++img_num) {
182 EXPECT_EQ(kImageData[image_ids_for_page[img_num]], 181 EXPECT_EQ(kImageData[image_ids_for_page[img_num]],
183 page.image(img_num).data()); 182 page.image(img_num).data());
184 EXPECT_EQ(GetImageName(page_num + 1, img_num), 183 EXPECT_EQ(GetImageName(page_num + 1, img_num),
185 page.image(img_num).name()); 184 page.image(img_num).name());
186 } 185 }
187 } 186 }
188 } 187 }
189 188
190 void AddComponentsResources() {
191 base::FilePath pak_file;
192 base::FilePath pak_dir;
193 PathService::Get(base::DIR_MODULE, &pak_dir);
194 pak_file = pak_dir.Append(FILE_PATH_LITERAL("components_resources.pak"));
195 ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
196 pak_file, ui::SCALE_FACTOR_NONE);
197 }
198
199 } // namespace 189 } // namespace
200 190
201 namespace dom_distiller { 191 namespace dom_distiller {
202 192
203 using test::MockDistillerPage; 193 using test::MockDistillerPage;
204 using test::MockDistillerPageFactory; 194 using test::MockDistillerPageFactory;
205 195
206 class TestDistillerURLFetcher : public DistillerURLFetcher { 196 class TestDistillerURLFetcher : public DistillerURLFetcher {
207 public: 197 public:
208 explicit TestDistillerURLFetcher(bool delay_fetch) 198 explicit TestDistillerURLFetcher(bool delay_fetch)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 MockDistillerURLFetcherFactory() : DistillerURLFetcherFactory(NULL) {} 240 MockDistillerURLFetcherFactory() : DistillerURLFetcherFactory(NULL) {}
251 virtual ~MockDistillerURLFetcherFactory() {} 241 virtual ~MockDistillerURLFetcherFactory() {}
252 242
253 MOCK_CONST_METHOD0(CreateDistillerURLFetcher, DistillerURLFetcher*()); 243 MOCK_CONST_METHOD0(CreateDistillerURLFetcher, DistillerURLFetcher*());
254 }; 244 };
255 245
256 class DistillerTest : public testing::Test { 246 class DistillerTest : public testing::Test {
257 public: 247 public:
258 virtual ~DistillerTest() {} 248 virtual ~DistillerTest() {}
259 249
260 virtual void SetUp() OVERRIDE {
261 AddComponentsResources();
262 }
263
264 void OnDistillArticleDone(scoped_ptr<DistilledArticleProto> proto) { 250 void OnDistillArticleDone(scoped_ptr<DistilledArticleProto> proto) {
265 article_proto_ = proto.Pass(); 251 article_proto_ = proto.Pass();
266 } 252 }
267 253
268 void OnDistillArticleUpdate(const ArticleDistillationUpdate& article_update) { 254 void OnDistillArticleUpdate(const ArticleDistillationUpdate& article_update) {
269 in_sequence_updates_.push_back(article_update); 255 in_sequence_updates_.push_back(article_update);
270 } 256 }
271 257
272 void DistillPage(const std::string& url, 258 void DistillPage(const std::string& url,
273 scoped_ptr<DistillerPage> distiller_page) { 259 scoped_ptr<DistillerPage> distiller_page) {
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 627
642 ASSERT_TRUE(distiller_page); 628 ASSERT_TRUE(distiller_page);
643 // Post the task to execute javascript and then delete the distiller. 629 // Post the task to execute javascript and then delete the distiller.
644 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get()); 630 distiller_page->OnDistillationDone(GURL(kURL), distilled_value.get());
645 distiller_.reset(); 631 distiller_.reset();
646 632
647 base::MessageLoop::current()->RunUntilIdle(); 633 base::MessageLoop::current()->RunUntilIdle();
648 } 634 }
649 635
650 } // namespace dom_distiller 636 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | ui/base/resource/data_pack_literal.cc » ('j') | ui/base/resource/resource_bundle_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698