1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "core/internal/mediums/bluetooth_radio.h"
16 
17 #include "gmock/gmock.h"
18 #include "gtest/gtest.h"
19 
20 namespace location {
21 namespace nearby {
22 namespace connections {
23 namespace {
24 
TEST(BluetoothRadioTest,ConstructorDestructorWorks)25 TEST(BluetoothRadioTest, ConstructorDestructorWorks) {
26   BluetoothRadio radio;
27   EXPECT_TRUE(radio.IsAdapterValid());
28 }
29 
TEST(BluetoothRadioTest,CanEnable)30 TEST(BluetoothRadioTest, CanEnable) {
31   BluetoothRadio radio;
32   EXPECT_TRUE(radio.IsAdapterValid());
33   EXPECT_FALSE(radio.IsEnabled());
34   EXPECT_TRUE(radio.Enable());
35   EXPECT_TRUE(radio.IsEnabled());
36 }
37 
TEST(BluetoothRadioTest,CanDisable)38 TEST(BluetoothRadioTest, CanDisable) {
39   BluetoothRadio radio;
40   EXPECT_TRUE(radio.IsAdapterValid());
41   EXPECT_FALSE(radio.IsEnabled());
42   EXPECT_TRUE(radio.Enable());
43   EXPECT_TRUE(radio.IsEnabled());
44   EXPECT_TRUE(radio.Disable());
45   EXPECT_FALSE(radio.IsEnabled());
46 }
47 
TEST(BluetoothRadioTest,CanToggle)48 TEST(BluetoothRadioTest, CanToggle) {
49   BluetoothRadio radio;
50   EXPECT_TRUE(radio.IsAdapterValid());
51   EXPECT_FALSE(radio.IsEnabled());
52   EXPECT_TRUE(radio.Toggle());
53   EXPECT_TRUE(radio.IsEnabled());
54 }
55 
56 }  // namespace
57 }  // namespace connections
58 }  // namespace nearby
59 }  // namespace location
60