OLD | NEW |
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/task_tracker.h" | 5 #include "components/dom_distiller/core/task_tracker.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "components/dom_distiller/core/article_distillation_update.h" | 8 #include "components/dom_distiller/core/article_distillation_update.h" |
9 #include "components/dom_distiller/core/article_entry.h" | 9 #include "components/dom_distiller/core/article_entry.h" |
10 #include "components/dom_distiller/core/distilled_content_store.h" | 10 #include "components/dom_distiller/core/distilled_content_store.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 EXPECT_CALL(viewer_delegate, OnArticleReady(_)); | 153 EXPECT_CALL(viewer_delegate, OnArticleReady(_)); |
154 | 154 |
155 task_tracker.StartDistiller(&distiller_factory, | 155 task_tracker.StartDistiller(&distiller_factory, |
156 scoped_ptr<DistillerPage>().Pass()); | 156 scoped_ptr<DistillerPage>().Pass()); |
157 base::RunLoop().RunUntilIdle(); | 157 base::RunLoop().RunUntilIdle(); |
158 | 158 |
159 EXPECT_FALSE(cancel_callback.Cancelled()); | 159 EXPECT_FALSE(cancel_callback.Cancelled()); |
160 } | 160 } |
161 | 161 |
| 162 TEST_F(DomDistillerTaskTrackerTest, TestDistillerFails) { |
| 163 MockDistillerFactory distiller_factory; |
| 164 FakeDistiller* distiller = new FakeDistiller(false); |
| 165 EXPECT_CALL(distiller_factory, CreateDistillerImpl()) |
| 166 .WillOnce(Return(distiller)); |
| 167 |
| 168 TestCancelCallback cancel_callback; |
| 169 TaskTracker task_tracker( |
| 170 GetDefaultEntry(), cancel_callback.GetCallback(), NULL); |
| 171 |
| 172 FakeViewRequestDelegate viewer_delegate; |
| 173 scoped_ptr<ViewerHandle> handle(task_tracker.AddViewer(&viewer_delegate)); |
| 174 base::RunLoop().RunUntilIdle(); |
| 175 |
| 176 EXPECT_CALL(viewer_delegate, OnArticleReady(_)); |
| 177 |
| 178 task_tracker.StartDistiller(&distiller_factory, |
| 179 scoped_ptr<DistillerPage>().Pass()); |
| 180 distiller->RunDistillerCallback( |
| 181 scoped_ptr<DistilledArticleProto>(new DistilledArticleProto)); |
| 182 base::RunLoop().RunUntilIdle(); |
| 183 |
| 184 EXPECT_FALSE(cancel_callback.Cancelled()); |
| 185 } |
| 186 |
162 TEST_F(DomDistillerTaskTrackerTest, | 187 TEST_F(DomDistillerTaskTrackerTest, |
163 TestSaveCallbackCalledOnDistillationComplete) { | 188 TestSaveCallbackCalledOnDistillationComplete) { |
164 MockDistillerFactory distiller_factory; | 189 MockDistillerFactory distiller_factory; |
165 FakeDistiller* distiller = new FakeDistiller(true); | 190 FakeDistiller* distiller = new FakeDistiller(true); |
166 EXPECT_CALL(distiller_factory, CreateDistillerImpl()) | 191 EXPECT_CALL(distiller_factory, CreateDistillerImpl()) |
167 .WillOnce(Return(distiller)); | 192 .WillOnce(Return(distiller)); |
168 TestCancelCallback cancel_callback; | 193 TestCancelCallback cancel_callback; |
169 TaskTracker task_tracker( | 194 TaskTracker task_tracker( |
170 GetDefaultEntry(), cancel_callback.GetCallback(), NULL); | 195 GetDefaultEntry(), cancel_callback.GetCallback(), NULL); |
171 | 196 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 new DistilledArticleProto(distilled_article))); | 394 new DistilledArticleProto(distilled_article))); |
370 base::RunLoop().RunUntilIdle(); | 395 base::RunLoop().RunUntilIdle(); |
371 | 396 |
372 ASSERT_EQ(stored_distilled_article.SerializeAsString(), | 397 ASSERT_EQ(stored_distilled_article.SerializeAsString(), |
373 distilled_article.SerializeAsString()); | 398 distilled_article.SerializeAsString()); |
374 EXPECT_FALSE(cancel_callback.Cancelled()); | 399 EXPECT_FALSE(cancel_callback.Cancelled()); |
375 } | 400 } |
376 | 401 |
377 } // namespace test | 402 } // namespace test |
378 } // namespace dom_distiller | 403 } // namespace dom_distiller |
OLD | NEW |