Fix emulator build error
[platform/framework/web/chromium-efl.git] / services / device / device_service_test_base.h
1 // Copyright 2017 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 #ifndef SERVICES_DEVICE_DEVICE_SERVICE_TEST_BASE_H_
6 #define SERVICES_DEVICE_DEVICE_SERVICE_TEST_BASE_H_
7
8 #include "base/task/single_thread_task_runner.h"
9 #include "base/test/task_environment.h"
10 #include "build/build_config.h"
11 #include "mojo/public/cpp/bindings/remote.h"
12 #include "services/device/public/mojom/device_service.mojom.h"
13 #include "services/network/test/test_network_connection_tracker.h"
14 #include "services/network/test/test_url_loader_factory.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace device {
18
19 class DeviceService;
20 class FakeGeolocationManager;
21
22 const char kTestGeolocationApiKey[] = "FakeApiKeyForTest";
23
24 // Base class responsible to setup Device Service for test.
25 class DeviceServiceTestBase : public testing::Test {
26  public:
27   DeviceServiceTestBase();
28
29   DeviceServiceTestBase(const DeviceServiceTestBase&) = delete;
30   DeviceServiceTestBase& operator=(const DeviceServiceTestBase&) = delete;
31
32   ~DeviceServiceTestBase() override;
33
34   // NOTE: It's important to do service instantiation within SetUp instead of
35   // the constructor, as subclasses of this fixture may need to initialize some
36   // global state before the service is constructed.
37   void SetUp() override;
38
39  protected:
40   mojom::DeviceService* device_service() { return service_remote_.get(); }
41   DeviceService* device_service_impl() { return service_.get(); }
42
43   // Can optionally be called to destroy the service before a child test fixture
44   // shuts down, in case the DeviceService has dependencies on objects created
45   // by the child test fixture.
46   void DestroyDeviceService();
47
48   base::test::TaskEnvironment task_environment_;
49
50   // Both of these task runners should be deprecated in favor of individual
51   // components of the device service creating their own.
52   scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
53   scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
54
55 #if BUILDFLAG(IS_APPLE)
56   std::unique_ptr<FakeGeolocationManager> fake_geolocation_manager_;
57 #endif
58
59   network::TestURLLoaderFactory test_url_loader_factory_;
60
61  private:
62   std::unique_ptr<network::TestNetworkConnectionTracker>
63       network_connection_tracker_;
64   std::unique_ptr<DeviceService> service_;
65   mojo::Remote<mojom::DeviceService> service_remote_;
66 };
67
68 }  // namespace device
69
70 #endif  // SERVICES_DEVICE_DEVICE_SERVICE_TEST_BASE_H_