| 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_entry.h" | 8 #include "components/dom_distiller/core/article_entry.h" |
| 9 #include "components/dom_distiller/core/fake_distiller.h" | 9 #include "components/dom_distiller/core/fake_distiller.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 using testing::Return; | 12 using testing::Return; |
| 13 using testing::_; | 13 using testing::_; |
| 14 | 14 |
| 15 namespace dom_distiller { | 15 namespace dom_distiller { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 class FakeViewRequestDelegate : public ViewRequestDelegate { | 18 class FakeViewRequestDelegate : public ViewRequestDelegate { |
| 19 public: | 19 public: |
| 20 virtual ~FakeViewRequestDelegate() {} | 20 virtual ~FakeViewRequestDelegate() {} |
| 21 MOCK_METHOD1(OnArticleReady, void(DistilledPageProto* proto)); | 21 MOCK_METHOD1(OnArticleReady, |
| 22 void(const DistilledArticleProto* article_proto)); |
| 22 }; | 23 }; |
| 23 | 24 |
| 24 class TestCancelCallback { | 25 class TestCancelCallback { |
| 25 public: | 26 public: |
| 26 TestCancelCallback() : cancelled_(false) {} | 27 TestCancelCallback() : cancelled_(false) {} |
| 27 TaskTracker::CancelCallback GetCallback() { | 28 TaskTracker::CancelCallback GetCallback() { |
| 28 return base::Bind(&TestCancelCallback::Cancel, base::Unretained(this)); | 29 return base::Bind(&TestCancelCallback::Cancel, base::Unretained(this)); |
| 29 } | 30 } |
| 30 void Cancel(TaskTracker*) { cancelled_ = true; } | 31 void Cancel(TaskTracker*) { cancelled_ = true; } |
| 31 bool Cancelled() { return cancelled_; } | 32 bool Cancelled() { return cancelled_; } |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 bool cancelled_; | 35 bool cancelled_; |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 class MockSaveCallback { | 38 class MockSaveCallback { |
| 38 public: | 39 public: |
| 39 MOCK_METHOD3(Save, void(const ArticleEntry&, DistilledPageProto*, bool)); | 40 MOCK_METHOD3(Save, |
| 41 void(const ArticleEntry&, const DistilledArticleProto*, bool)); |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 class DomDistillerTaskTrackerTest : public testing::Test { | 44 class DomDistillerTaskTrackerTest : public testing::Test { |
| 43 public: | 45 public: |
| 44 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 45 message_loop_.reset(new base::MessageLoop()); | 47 message_loop_.reset(new base::MessageLoop()); |
| 46 entry_id_ = "id0"; | 48 entry_id_ = "id0"; |
| 47 page_0_url_ = GURL("http://www.example.com/1"); | 49 page_0_url_ = GURL("http://www.example.com/1"); |
| 48 page_1_url_ = GURL("http://www.example.com/2"); | 50 page_1_url_ = GURL("http://www.example.com/2"); |
| 49 } | 51 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 EXPECT_CALL(save_callback, Save(_, _, _)); | 156 EXPECT_CALL(save_callback, Save(_, _, _)); |
| 155 | 157 |
| 156 task_tracker.StartDistiller(&distiller_factory); | 158 task_tracker.StartDistiller(&distiller_factory); |
| 157 base::RunLoop().RunUntilIdle(); | 159 base::RunLoop().RunUntilIdle(); |
| 158 | 160 |
| 159 EXPECT_TRUE(cancel_callback.Cancelled()); | 161 EXPECT_TRUE(cancel_callback.Cancelled()); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace test | 164 } // namespace test |
| 163 } // namespace dom_distiller | 165 } // namespace dom_distiller |
| OLD | NEW |