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

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

Issue 82353002: Move more webdata unittests into components_unittests target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: InitSharedInstance Created 7 years 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
« no previous file with comments | « components/components_tests.gyp ('k') | components/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map> 5 #include <map>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "components/dom_distiller/core/distiller.h" 13 #include "components/dom_distiller/core/distiller.h"
14 #include "components/dom_distiller/core/distiller_page.h" 14 #include "components/dom_distiller/core/distiller_page.h"
15 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 15 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
16 #include "net/url_request/url_request_context_getter.h" 16 #include "net/url_request/url_request_context_getter.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
Lei Zhang 2013/11/22 19:37:04 nit: remove
20 20
21 #if defined(OS_ANDROID) 21 #if defined(OS_ANDROID)
22 #include "base/android/jni_android.h" 22 #include "base/android/jni_android.h"
23 #include "ui/base/android/ui_base_jni_registrar.h" 23 #include "ui/base/android/ui_base_jni_registrar.h"
24 #include "ui/gfx/android/gfx_jni_registrar.h" 24 #include "ui/gfx/android/gfx_jni_registrar.h"
25 #endif 25 #endif
26 26
27 using::testing::Invoke; 27 using::testing::Invoke;
28 using::testing::Return; 28 using::testing::Return;
29 using::testing::_; 29 using::testing::_;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 TEST_F(DistillerTest, DistillPage) { 135 TEST_F(DistillerTest, DistillPage) {
136 #if defined(OS_ANDROID) 136 #if defined(OS_ANDROID)
137 // Register JNI bindings for android. 137 // Register JNI bindings for android.
138 JNIEnv* env = base::android::AttachCurrentThread(); 138 JNIEnv* env = base::android::AttachCurrentThread();
139 gfx::android::RegisterJni(env); 139 gfx::android::RegisterJni(env);
140 ui::android::RegisterJni(env); 140 ui::android::RegisterJni(env);
141 #endif 141 #endif
142 142
143 ui::ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL);
144 base::MessageLoop loop(base::MessageLoop::TYPE_UI); 143 base::MessageLoop loop(base::MessageLoop::TYPE_UI);
145 scoped_ptr<base::ListValue> list(new base::ListValue()); 144 scoped_ptr<base::ListValue> list(new base::ListValue());
146 list->AppendString(kTitle); 145 list->AppendString(kTitle);
147 list->AppendString(kContent); 146 list->AppendString(kContent);
148 list->AppendString(kImageURL0); 147 list->AppendString(kImageURL0);
149 list->AppendString(kImageURL1); 148 list->AppendString(kImageURL1);
150 EXPECT_CALL(page_factory_, 149 EXPECT_CALL(page_factory_,
151 CreateDistillerPageMock(_)).WillOnce( 150 CreateDistillerPageMock(_)).WillOnce(
152 CreateMockDistillerPage(list.get(), GURL(kURL))); 151 CreateMockDistillerPage(list.get(), GURL(kURL)));
153 distiller_.reset(new DistillerImpl(page_factory_, url_fetcher_factory_)); 152 distiller_.reset(new DistillerImpl(page_factory_, url_fetcher_factory_));
154 distiller_->Init(); 153 distiller_->Init();
155 distiller_->DistillPage( 154 distiller_->DistillPage(
156 GURL(kURL), 155 GURL(kURL),
157 base::Bind(&DistillerTest::OnDistillPageDone, base::Unretained(this))); 156 base::Bind(&DistillerTest::OnDistillPageDone, base::Unretained(this)));
158 base::MessageLoop::current()->RunUntilIdle(); 157 base::MessageLoop::current()->RunUntilIdle();
159 EXPECT_EQ(kTitle, proto_->title()); 158 EXPECT_EQ(kTitle, proto_->title());
160 EXPECT_EQ(kContent, proto_->html()); 159 EXPECT_EQ(kContent, proto_->html());
161 EXPECT_EQ(kURL, proto_->url()); 160 EXPECT_EQ(kURL, proto_->url());
162 EXPECT_EQ(2, proto_->image_size()); 161 EXPECT_EQ(2, proto_->image_size());
163 EXPECT_EQ(kImageData0, proto_->image(0).data()); 162 EXPECT_EQ(kImageData0, proto_->image(0).data());
164 EXPECT_EQ(kId0, proto_->image(0).name()); 163 EXPECT_EQ(kId0, proto_->image(0).name());
165 EXPECT_EQ(kImageData1, proto_->image(1).data()); 164 EXPECT_EQ(kImageData1, proto_->image(1).data());
166 EXPECT_EQ(kId1, proto_->image(1).name()); 165 EXPECT_EQ(kId1, proto_->image(1).name());
167 } 166 }
168 167
169 } // namespace dom_distiller 168 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/components_tests.gyp ('k') | components/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698