1 //===-- AdbClientTest.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
10 #include "Plugins/Platform/Android/AdbClient.h"
13 static void set_env(const char *var
, const char *value
) {
15 _putenv_s(var
, value
);
17 setenv(var
, value
, true);
22 using namespace lldb_private
;
24 namespace lldb_private
{
25 namespace platform_android
{
27 class AdbClientTest
: public ::testing::Test
{
29 void SetUp() override
{ set_env("ANDROID_SERIAL", ""); }
31 void TearDown() override
{ set_env("ANDROID_SERIAL", ""); }
34 TEST(AdbClientTest
, CreateByDeviceId
) {
36 Status error
= AdbClient::CreateByDeviceID("device1", adb
);
37 EXPECT_TRUE(error
.Success());
38 EXPECT_EQ("device1", adb
.GetDeviceID());
41 TEST(AdbClientTest
, CreateByDeviceId_ByEnvVar
) {
42 set_env("ANDROID_SERIAL", "device2");
45 Status error
= AdbClient::CreateByDeviceID("", adb
);
46 EXPECT_TRUE(error
.Success());
47 EXPECT_EQ("device2", adb
.GetDeviceID());
50 } // end namespace platform_android
51 } // end namespace lldb_private