1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "base/functional/bind.h"
8 #include "base/test/bind.h"
9 #include "components/services/patch/content/patch_service.h"
10 #include "components/services/patch/public/mojom/file_patcher.mojom.h"
11 #include "components/services/unzip/content/unzip_service.h"
12 #include "components/services/unzip/public/mojom/unzipper.mojom.h"
13 #include "content/public/test/browser_task_environment.h"
14 #include "content/public/test/test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h"
19 class ServicesTest : public testing::Test {
22 : task_environment_(content::BrowserTaskEnvironment::MainThreadType::IO) {
25 ServicesTest(const ServicesTest&) = delete;
26 ServicesTest& operator=(const ServicesTest&) = delete;
28 template <typename Interface>
29 bool IsConnected(mojo::Remote<Interface>* remote) {
30 bool connected = true;
31 remote->set_disconnect_handler(
32 base::BindLambdaForTesting([&] { connected = false; }));
33 remote->FlushForTesting();
38 content::BrowserTaskEnvironment task_environment_;
39 content::InProcessUtilityThreadHelper in_process_utility_thread_helper_;
44 TEST_F(ServicesTest, ConnectToUnzip) {
45 mojo::Remote<unzip::mojom::Unzipper> unzipper(unzip::LaunchUnzipper());
46 EXPECT_TRUE(IsConnected(&unzipper));
49 TEST_F(ServicesTest, ConnectToFilePatch) {
50 mojo::Remote<patch::mojom::FilePatcher> patcher(patch::LaunchFilePatcher());
51 EXPECT_TRUE(IsConnected(&patcher));