From 09a7dc8eb325accd83c0a3de87a899df6a489451 Mon Sep 17 00:00:00 2001 From: Edwin Wu Date: Wed, 13 Aug 2025 10:39:37 -0700 Subject: [PATCH] [NC Apple coverage] Add GNCDeviceInfoTest unit test to cover the device info APIs for Nearby. PiperOrigin-RevId: 794643095 --- .../platform/implementation/apple/Tests/BUILD | 1 + .../apple/Tests/GNCDeviceInfoTest.mm | 87 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 internal/platform/implementation/apple/Tests/GNCDeviceInfoTest.mm diff --git a/internal/platform/implementation/apple/Tests/BUILD b/internal/platform/implementation/apple/Tests/BUILD index 22c6e1b0..258639ca 100644 --- a/internal/platform/implementation/apple/Tests/BUILD +++ b/internal/platform/implementation/apple/Tests/BUILD @@ -40,6 +40,7 @@ objc_library( "GNCBLEMediumTest.m", "GNCBLEUtilsTest.mm", "GNCCryptoTest.mm", + "GNCDeviceInfoTest.mm", "GNCFakeCentralManager.h", "GNCFakeCentralManager.m", "GNCFakePeripheral.h", diff --git a/internal/platform/implementation/apple/Tests/GNCDeviceInfoTest.mm b/internal/platform/implementation/apple/Tests/GNCDeviceInfoTest.mm new file mode 100644 index 00000000..39988866 --- /dev/null +++ b/internal/platform/implementation/apple/Tests/GNCDeviceInfoTest.mm @@ -0,0 +1,87 @@ +// Copyright 2023 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. + +#import + +#include "internal/platform/implementation/apple/device_info.h" + +#include +#include + +@interface GNCDeviceInfoTest : XCTestCase +@end + +@implementation GNCDeviceInfoTest { + std::unique_ptr _deviceInfo; +} + +- (void)setUp { + [super setUp]; + _deviceInfo = std::make_unique(); +} + +- (void)tearDown { + _deviceInfo.reset(); + [super tearDown]; +} + +- (void)testGetOsDeviceName { + XCTAssertNotNil(@(_deviceInfo->GetOsDeviceName().value().c_str())); +} + +- (void)testGetDeviceType { + XCTAssertNoThrow(_deviceInfo->GetDeviceType()); +} + +- (void)testGetOsType { + XCTAssertNoThrow(_deviceInfo->GetOsType()); +} + +- (void)testGetDownloadPath { + XCTAssertNotNil(@(_deviceInfo->GetDownloadPath().value().GetPath().c_str())); +} + +- (void)testGetLocalAppDataPath { + XCTAssertNotNil(@(_deviceInfo->GetLocalAppDataPath().value().GetPath().c_str())); +} + +- (void)testGetCommonAppDataPath { + XCTAssertNotNil(@(_deviceInfo->GetCommonAppDataPath().value().GetPath().c_str())); +} + +- (void)testGetTemporaryPath { + XCTAssertNotNil(@(_deviceInfo->GetTemporaryPath().value().GetPath().c_str())); +} + +- (void)testGetLogPath { + XCTAssertNotNil(@(_deviceInfo->GetLogPath().value().GetPath().c_str())); +} + +- (void)testGetCrashDumpPath { + XCTAssertNotNil(@(_deviceInfo->GetCrashDumpPath().value().GetPath().c_str())); +} + +- (void)testIsScreenLocked { + XCTAssertFalse(_deviceInfo->IsScreenLocked()); +} + +- (void)testPreventSleep { + XCTAssertTrue(_deviceInfo->PreventSleep()); +} + +- (void)testAllowSleep { + XCTAssertTrue(_deviceInfo->AllowSleep()); +} + +@end