[M120][Tizen][Onscreen] Fix build errors for TV profile
[platform/framework/web/chromium-efl.git] / chrome / browser / services_unittest.cc
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.
4
5 #include <string>
6
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"
16
17 namespace {
18
19 class ServicesTest : public testing::Test {
20  public:
21   ServicesTest()
22       : task_environment_(content::BrowserTaskEnvironment::MainThreadType::IO) {
23   }
24
25   ServicesTest(const ServicesTest&) = delete;
26   ServicesTest& operator=(const ServicesTest&) = delete;
27
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();
34     return connected;
35   }
36
37  private:
38   content::BrowserTaskEnvironment task_environment_;
39   content::InProcessUtilityThreadHelper in_process_utility_thread_helper_;
40 };
41
42 }  // namespace
43
44 TEST_F(ServicesTest, ConnectToUnzip) {
45   mojo::Remote<unzip::mojom::Unzipper> unzipper(unzip::LaunchUnzipper());
46   EXPECT_TRUE(IsConnected(&unzipper));
47 }
48
49 TEST_F(ServicesTest, ConnectToFilePatch) {
50   mojo::Remote<patch::mojom::FilePatcher> patcher(patch::LaunchFilePatcher());
51   EXPECT_TRUE(IsConnected(&patcher));
52 }