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

Side by Side Diff: components/previews/previews_io_data_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_io_data.h" 5 #include "components/previews/previews_io_data.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"
(...skipping 12 matching lines...) Expand all
23 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 23 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
24 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) 24 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
25 : PreviewsIOData(io_task_runner, ui_task_runner), initialized_(false) {} 25 : PreviewsIOData(io_task_runner, ui_task_runner), initialized_(false) {}
26 ~TestPreviewsIOData() override {} 26 ~TestPreviewsIOData() override {}
27 27
28 // Whether Initialize was called. 28 // Whether Initialize was called.
29 bool initialized() { return initialized_; } 29 bool initialized() { return initialized_; }
30 30
31 private: 31 private:
32 // Set |initialized_| to true and use base class functionality. 32 // Set |initialized_| to true and use base class functionality.
33 void InitializeOnIOThread() override { 33 void InitializeOnIOThread(
34 std::unique_ptr<PreviewsOptOutStore> previews_opt_out_store) override {
34 initialized_ = true; 35 initialized_ = true;
35 PreviewsIOData::InitializeOnIOThread(); 36 PreviewsIOData::InitializeOnIOThread(std::move(previews_opt_out_store));
36 } 37 }
37 38
38 // Whether Initialize was called. 39 // Whether Initialize was called.
39 bool initialized_; 40 bool initialized_;
40 }; 41 };
41 42
42 class PreviewsIODataTest : public testing::Test { 43 class PreviewsIODataTest : public testing::Test {
43 public: 44 public:
44 PreviewsIODataTest() {} 45 PreviewsIODataTest() {}
45 46
(...skipping 16 matching lines...) Expand all
62 private: 63 private:
63 std::unique_ptr<TestPreviewsIOData> io_data_; 64 std::unique_ptr<TestPreviewsIOData> io_data_;
64 std::unique_ptr<PreviewsUIService> ui_service_; 65 std::unique_ptr<PreviewsUIService> ui_service_;
65 }; 66 };
66 67
67 } // namespace 68 } // namespace
68 69
69 TEST_F(PreviewsIODataTest, TestInitialization) { 70 TEST_F(PreviewsIODataTest, TestInitialization) {
70 set_io_data(base::WrapUnique( 71 set_io_data(base::WrapUnique(
71 new TestPreviewsIOData(loop_.task_runner(), loop_.task_runner()))); 72 new TestPreviewsIOData(loop_.task_runner(), loop_.task_runner())));
72 set_ui_service( 73 set_ui_service(base::WrapUnique(
73 base::WrapUnique(new PreviewsUIService(io_data(), loop_.task_runner()))); 74 new PreviewsUIService(io_data(), loop_.task_runner(), nullptr)));
74 loop_.RunUntilIdle(); 75 loop_.RunUntilIdle();
75 // After the outstanding posted tasks have run, |io_data_| should be fully 76 // After the outstanding posted tasks have run, |io_data_| should be fully
76 // initialized. 77 // initialized.
77 EXPECT_TRUE(io_data()->initialized()); 78 EXPECT_TRUE(io_data()->initialized());
78 } 79 }
79 80
80 } // namespace previews 81 } // namespace previews
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698