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

Side by Side Diff: components/previews/previews_ui_service_unittest.cc

Issue 2335023002: Adding a previews IO-thread blacklist (Closed)
Patch Set: tbansal comments Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/previews/previews_ui_service.h" 5 #include "components/previews/previews_ui_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "components/previews/previews_io_data.h" 13 #include "components/previews/previews_io_data.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace previews { 16 namespace previews {
17 17
18 namespace { 18 namespace {
19 19
20 class TestPreviewsUIService : public PreviewsUIService { 20 class TestPreviewsUIService : public PreviewsUIService {
21 public: 21 public:
22 TestPreviewsUIService( 22 TestPreviewsUIService(
23 PreviewsIOData* previews_io_data, 23 PreviewsIOData* previews_io_data,
24 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) 24 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
25 : PreviewsUIService(previews_io_data, io_task_runner), 25 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store)
26 : PreviewsUIService(previews_io_data,
27 io_task_runner,
28 std::move(previews_opt_out_store)),
26 io_data_set_(false) {} 29 io_data_set_(false) {}
27 ~TestPreviewsUIService() override {} 30 ~TestPreviewsUIService() override {}
28 31
29 // Set |io_data_set_| to true and use base class functionality. 32 // Set |io_data_set_| to true and use base class functionality.
30 void SetIOData(base::WeakPtr<PreviewsIOData> previews_io_data) override { 33 void SetIOData(base::WeakPtr<PreviewsIOData> previews_io_data) override {
31 io_data_set_ = true; 34 io_data_set_ = true;
32 PreviewsUIService::SetIOData(previews_io_data); 35 PreviewsUIService::SetIOData(previews_io_data);
33 } 36 }
34 37
35 // Whether SetIOData was called. 38 // Whether SetIOData was called.
(...skipping 30 matching lines...) Expand all
66 std::unique_ptr<PreviewsIOData> io_data_; 69 std::unique_ptr<PreviewsIOData> io_data_;
67 std::unique_ptr<TestPreviewsUIService> ui_service_; 70 std::unique_ptr<TestPreviewsUIService> ui_service_;
68 }; 71 };
69 72
70 } // namespace 73 } // namespace
71 74
72 TEST_F(PreviewsUIServiceTest, TestInitialization) { 75 TEST_F(PreviewsUIServiceTest, TestInitialization) {
73 set_io_data(base::WrapUnique( 76 set_io_data(base::WrapUnique(
74 new PreviewsIOData(loop_.task_runner(), loop_.task_runner()))); 77 new PreviewsIOData(loop_.task_runner(), loop_.task_runner())));
75 set_ui_service(base::WrapUnique( 78 set_ui_service(base::WrapUnique(
76 new TestPreviewsUIService(io_data(), loop_.task_runner()))); 79 new TestPreviewsUIService(io_data(), loop_.task_runner(), nullptr)));
77 loop_.RunUntilIdle(); 80 loop_.RunUntilIdle();
78 // After the outstanding posted tasks have run, SetIOData should have been 81 // After the outstanding posted tasks have run, SetIOData should have been
79 // called for |ui_service_|. 82 // called for |ui_service_|.
80 EXPECT_TRUE(ui_service()->io_data_set()); 83 EXPECT_TRUE(ui_service()->io_data_set());
81 } 84 }
82 85
83 } // namespace previews 86 } // namespace previews
OLDNEW
« components/previews/previews_opt_out_store.h ('K') | « components/previews/previews_ui_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698