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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_content_file_system_file_stream_reader_unittest.cc

Issue 2552223002: Remove explicit singletonness of ArcBridgeService part 2. (Closed)
Patch Set: Address comment Created 4 years 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 <memory>
5 #include <string> 6 #include <string>
6 #include <utility> 7 #include <utility>
7 8
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
10 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/memory/ptr_util.h"
11 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
12 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_file_strea m_reader.h" 14 #include "chrome/browser/chromeos/arc/fileapi/arc_content_file_system_file_strea m_reader.h"
15 #include "components/arc/arc_service_manager.h"
13 #include "components/arc/test/fake_arc_bridge_service.h" 16 #include "components/arc/test/fake_arc_bridge_service.h"
14 #include "components/arc/test/fake_file_system_instance.h" 17 #include "components/arc/test/fake_file_system_instance.h"
15 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "mojo/edk/embedder/embedder.h" 19 #include "mojo/edk/embedder/embedder.h"
17 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
18 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 23
21 namespace arc { 24 namespace arc {
22 25
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ~ArcContentFileSystemFileStreamReaderTest() override = default; 76 ~ArcContentFileSystemFileStreamReaderTest() override = default;
74 77
75 void SetUp() override { 78 void SetUp() override {
76 mojo::edk::Init(); 79 mojo::edk::Init();
77 80
78 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 81 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
79 82
80 base::FilePath path = temp_dir_.GetPath().AppendASCII("bar"); 83 base::FilePath path = temp_dir_.GetPath().AppendASCII("bar");
81 ASSERT_TRUE(base::WriteFile(path, kData, arraysize(kData))); 84 ASSERT_TRUE(base::WriteFile(path, kData, arraysize(kData)));
82 85
83 file_system_.reset(new ArcFileSystemInstanceTestImpl(path)); 86 file_system_ = base::MakeUnique<ArcFileSystemInstanceTestImpl>(path);
84 87
85 fake_arc_bridge_service_.file_system()->SetInstance(file_system_.get()); 88 ArcServiceManager::SetArcBridgeServiceForTesting(
89 base::MakeUnique<FakeArcBridgeService>());
90 arc_service_manager_ = base::MakeUnique<ArcServiceManager>(nullptr);
91 arc_service_manager_->arc_bridge_service()->file_system()->SetInstance(
92 file_system_.get());
93 }
94
95 void TearDown() override {
96 arc_service_manager_->arc_bridge_service()->file_system()->SetInstance(
hashimoto 2016/12/07 04:15:50 Why do we need to do this? The same goes for the o
hidehiko 2016/12/08 08:13:21 Hmm, I wanted to emulate the real tear down situat
97 nullptr);
98 arc_service_manager_.reset();
hashimoto 2016/12/07 04:15:50 Why can't we let the dtor handle resetting these u
hidehiko 2016/12/08 08:13:21 Acknowledged.
99
100 file_system_.reset();
Luis Héctor Chávez 2016/12/06 19:14:37 nit: Try adding mojo::edk::test::Shutdown()[1] her
hidehiko 2016/12/08 08:13:21 I haven't investigated yet, but causes a crash err
86 } 101 }
87 102
88 private: 103 private:
89 base::ScopedTempDir temp_dir_; 104 base::ScopedTempDir temp_dir_;
90 content::TestBrowserThreadBundle thread_bundle_; 105 content::TestBrowserThreadBundle thread_bundle_;
91 FakeArcBridgeService fake_arc_bridge_service_;
92 std::unique_ptr<ArcFileSystemInstanceTestImpl> file_system_; 106 std::unique_ptr<ArcFileSystemInstanceTestImpl> file_system_;
107 std::unique_ptr<ArcServiceManager> arc_service_manager_;
hashimoto 2016/12/07 04:15:50 In the other test, arc_service_manager_ is placed
hidehiko 2016/12/08 08:13:21 Done.
93 108
94 DISALLOW_COPY_AND_ASSIGN(ArcContentFileSystemFileStreamReaderTest); 109 DISALLOW_COPY_AND_ASSIGN(ArcContentFileSystemFileStreamReaderTest);
95 }; 110 };
96 111
97 } // namespace 112 } // namespace
98 113
99 TEST_F(ArcContentFileSystemFileStreamReaderTest, Read) { 114 TEST_F(ArcContentFileSystemFileStreamReaderTest, Read) {
100 ArcContentFileSystemFileStreamReader reader(GURL(kArcUrl), 0); 115 ArcContentFileSystemFileStreamReader reader(GURL(kArcUrl), 0);
101 116
102 auto base_buffer = 117 auto base_buffer =
(...skipping 14 matching lines...) Expand all
117 132
118 TEST_F(ArcContentFileSystemFileStreamReaderTest, GetLength) { 133 TEST_F(ArcContentFileSystemFileStreamReaderTest, GetLength) {
119 ArcContentFileSystemFileStreamReader reader(GURL(kArcUrl), 0); 134 ArcContentFileSystemFileStreamReader reader(GURL(kArcUrl), 0);
120 135
121 net::TestInt64CompletionCallback callback; 136 net::TestInt64CompletionCallback callback;
122 EXPECT_EQ(static_cast<int64_t>(arraysize(kData)), 137 EXPECT_EQ(static_cast<int64_t>(arraysize(kData)),
123 callback.GetResult(reader.GetLength(callback.callback()))); 138 callback.GetResult(reader.GetLength(callback.callback())));
124 } 139 }
125 140
126 } // namespace arc 141 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698