mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Add tests for sharing_platform_base.
PiperOrigin-RevId: 629794040
This commit is contained in:
committed by
Copybara-Service
parent
63b1f24432
commit
8e3cfd04f8
@@ -61,10 +61,14 @@ cc_library(
|
||||
"fake_nearby_share_client.h",
|
||||
"mock_app_info.h",
|
||||
"mock_bluetooth_adapter.h",
|
||||
"mock_fast_init_ble_beacon.h",
|
||||
"mock_fast_initiation_manager.h",
|
||||
"mock_network_monitor.h",
|
||||
"mock_public_certificate_db.h",
|
||||
"mock_sharing_platform.h",
|
||||
"mock_shell.h",
|
||||
"mock_system_info.h",
|
||||
"mock_wifi_adapter.h",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INIT_BLE_BEACON_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INIT_BLE_BEACON_H_
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "sharing/internal/api/fast_init_ble_beacon.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
|
||||
class MockFastInitBleBeacon : public nearby::api::FastInitBleBeacon {
|
||||
public:
|
||||
MockFastInitBleBeacon() = default;
|
||||
MockFastInitBleBeacon(const MockFastInitBleBeacon&) = delete;
|
||||
MockFastInitBleBeacon& operator=(const MockFastInitBleBeacon&) = delete;
|
||||
~MockFastInitBleBeacon() override = default;
|
||||
|
||||
MOCK_METHOD(void, SerializeToByteArray, (), (override));
|
||||
MOCK_METHOD(void, ParseFromByteArray, (), (override));
|
||||
};
|
||||
|
||||
} // namespace nearby::sharing::api
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INIT_BLE_BEACON_H_
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INITIATION_MANAGER_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INITIATION_MANAGER_H_
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "sharing/internal/api/fast_init_ble_beacon.h"
|
||||
#include "sharing/internal/api/fast_initiation_manager.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
|
||||
class MockFastInitiationManager : public nearby::api::FastInitiationManager {
|
||||
public:
|
||||
MockFastInitiationManager() = default;
|
||||
MockFastInitiationManager(const MockFastInitiationManager&) = delete;
|
||||
MockFastInitiationManager& operator=(const MockFastInitiationManager&) =
|
||||
delete;
|
||||
~MockFastInitiationManager() override = default;
|
||||
|
||||
MOCK_METHOD(void, StartAdvertising,
|
||||
(nearby::api::FastInitBleBeacon::FastInitType type,
|
||||
std::function<void()> callback,
|
||||
std::function<void(nearby::api::FastInitiationManager::Error)>
|
||||
error_callback),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(void, StopAdvertising, (std::function<void()> callback),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(void, StartScanning,
|
||||
(std::function<void()> devices_discovered_callback,
|
||||
std::function<void()> devices_not_discovered_callback,
|
||||
std::function<void(nearby::api::FastInitiationManager::Error)>
|
||||
error_callback),
|
||||
(override));
|
||||
|
||||
MOCK_METHOD(void, StopScanning, (std::function<void()> callback), (override));
|
||||
|
||||
MOCK_METHOD(bool, IsAdvertising, (), (override));
|
||||
|
||||
MOCK_METHOD(bool, IsScanning, (), (override));
|
||||
};
|
||||
|
||||
} // namespace nearby::sharing::api
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_FAST_INITIATION_MANAGER_H_
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_SHELL_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_SHELL_H_
|
||||
|
||||
#include <filesystem> // NOLINT
|
||||
#include <functional>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "sharing/internal/api/shell.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
|
||||
class MockShell : public nearby::api::Shell {
|
||||
public:
|
||||
MockShell() = default;
|
||||
MockShell(const MockShell&) = delete;
|
||||
MockShell& operator=(const MockShell&) = delete;
|
||||
~MockShell() override = default;
|
||||
|
||||
MOCK_METHOD(void, Open,
|
||||
(const std::filesystem::path& path,
|
||||
std::function<void(absl::Status)> callback),
|
||||
(override));
|
||||
};
|
||||
|
||||
} // namespace nearby::sharing::api
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_SHELL_H_
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright 2024 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_WIFI_ADAPTER_H_
|
||||
#define THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_WIFI_ADAPTER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "sharing/internal/api/wifi_adapter.h"
|
||||
|
||||
namespace nearby::sharing::api {
|
||||
|
||||
class MockWifiAdapter : public nearby::sharing::api::WifiAdapter {
|
||||
public:
|
||||
MockWifiAdapter() = default;
|
||||
MockWifiAdapter(const MockWifiAdapter&) = delete;
|
||||
MockWifiAdapter& operator=(const MockWifiAdapter&) = delete;
|
||||
~MockWifiAdapter() override = default;
|
||||
|
||||
MOCK_METHOD(bool, IsPresent, (), (const, override));
|
||||
MOCK_METHOD(bool, IsPowered, (), (const, override));
|
||||
MOCK_METHOD(PermissionStatus, GetOsPermissionStatus, (), (const, override));
|
||||
MOCK_METHOD(void, SetPowered,
|
||||
(bool powered, std::function<void()> success_callback,
|
||||
std::function<void()> error_callback),
|
||||
(override));
|
||||
MOCK_METHOD(std::optional<std::string>, GetAdapterId, (), (const, override));
|
||||
MOCK_METHOD(void, AddObserver, (Observer * observer), (override));
|
||||
MOCK_METHOD(void, RemoveObserver, (Observer * observer), (override));
|
||||
MOCK_METHOD(bool, HasObserver, (Observer * observer), (override));
|
||||
MOCK_METHOD(void, JoinNetwork,
|
||||
(absl::string_view ssid, absl::string_view password,
|
||||
std::function<void(absl::Status)> callback),
|
||||
(override));
|
||||
};
|
||||
|
||||
} // namespace nearby::sharing::api
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_SHARING_INTERNAL_API_MOCK_WIFI_ADAPTER_H_
|
||||
Reference in New Issue
Block a user