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

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

Issue 2333003002: Changed previews component to be a layered component. (Closed)
Patch Set: Rebased on master 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
« no previous file with comments | « components/previews/previews_io_data.cc ('k') | components/previews/previews_ui_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/previews/previews_io_data.h"
6
7 #include <memory>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h"
14 #include "components/previews/previews_ui_service.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace previews {
18
19 namespace {
20
21 class TestPreviewsIOData : public PreviewsIOData {
22 public:
23 TestPreviewsIOData(
24 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
25 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
26 : PreviewsIOData(io_task_runner, ui_task_runner), initialized_(false) {}
27 ~TestPreviewsIOData() override {}
28
29 // Whether Initialize was called.
30 bool initialized() { return initialized_; }
31
32 private:
33 // Set |initialized_| to true and use base class functionality.
34 void InitializeOnIOThread() override {
35 initialized_ = true;
36 PreviewsIOData::InitializeOnIOThread();
37 }
38
39 // Whether Initialize was called.
40 bool initialized_;
41 };
42
43 class PreviewsIODataTest : public testing::Test {
44 public:
45 PreviewsIODataTest() {}
46
47 ~PreviewsIODataTest() override {}
48
49 void set_io_data(std::unique_ptr<TestPreviewsIOData> io_data) {
50 io_data_ = std::move(io_data);
51 }
52
53 TestPreviewsIOData* io_data() { return io_data_.get(); }
54
55 void set_ui_service(std::unique_ptr<PreviewsUIService> ui_service) {
56 ui_service_ = std::move(ui_service);
57 }
58
59 protected:
60 // Run this test on a single thread.
61 base::MessageLoopForIO loop_;
62
63 private:
64 std::unique_ptr<TestPreviewsIOData> io_data_;
65 std::unique_ptr<PreviewsUIService> ui_service_;
66 };
67
68 } // namespace
69
70 TEST_F(PreviewsIODataTest, TestInitialization) {
71 set_io_data(base::WrapUnique(
72 new TestPreviewsIOData(loop_.task_runner(), loop_.task_runner())));
73 set_ui_service(
74 base::WrapUnique(new PreviewsUIService(io_data(), loop_.task_runner())));
75 base::RunLoop().RunUntilIdle();
76 // After the outstanding posted tasks have run, |io_data_| should be fully
77 // initialized.
78 EXPECT_TRUE(io_data()->initialized());
79 }
80
81 } // namespace previews
OLDNEW
« no previous file with comments | « components/previews/previews_io_data.cc ('k') | components/previews/previews_ui_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698