[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / unittests / Platform / Android / AdbClientTest.cpp
blob0808b96f69fc8ac4fb98bcddab7cc85a57ccb863
1 //===-- AdbClientTest.cpp -------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
10 #include "Plugins/Platform/Android/AdbClient.h"
11 #include <cstdlib>
13 static void set_env(const char *var, const char *value) {
14 #ifdef _WIN32
15 _putenv_s(var, value);
16 #else
17 setenv(var, value, true);
18 #endif
21 using namespace lldb;
22 using namespace lldb_private;
24 namespace lldb_private {
25 namespace platform_android {
27 class AdbClientTest : public ::testing::Test {
28 public:
29 void SetUp() override { set_env("ANDROID_SERIAL", ""); }
31 void TearDown() override { set_env("ANDROID_SERIAL", ""); }
34 TEST(AdbClientTest, CreateByDeviceId) {
35 AdbClient adb;
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");
44 AdbClient adb;
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