• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025-2025 Huawei Device Co., Ltd.
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  *    http://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 
16 #include <gtest/gtest.h>
17 #include "telephony_errors.h"
18 #include "interoperable_device_observer.h"
19 #include "interoperable_communication_manager.h"
20 #include "telephony_permission.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 using namespace testing::ext;
25 
26 class InteroperableDeviceObserverTest : public testing::Test {
27 public:
SetUpTestCase()28     static void SetUpTestCase() {}
TearDownTestCase()29     static void TearDownTestCase() {}
SetUp()30     virtual void SetUp() {}
TearDown()31     virtual void TearDown() {}
32 };
33 
34 /**
35  * @tc.number   Telephony_InteroperableDeviceObserver_001
36  * @tc.name     test normal branch
37  * @tc.desc     normal branch test
38  */
39 HWTEST_F(InteroperableDeviceObserverTest, Telephony_InteroperableDeviceObserver_001, Function | MediumTest | Level1)
40 {
41     std::string devId = "UnitTestDeviceId";
42     std::string devName = "UnitTestDeviceName";
43     uint16_t deviceType = 1;
44     auto deviceObserver = std::make_shared<InteroperableDeviceObserver>();
45     std::shared_ptr<IInteroperableDeviceStateCallback> callback = nullptr;
46     ASSERT_NO_THROW(deviceObserver->Init());
47     ASSERT_NO_THROW(deviceObserver->RegisterDevStatusCallback(callback));
48     ASSERT_NO_THROW(deviceObserver->RegisterDevStatusCallback(callback)); // duplicate register
49     ASSERT_NO_THROW(deviceObserver->UnRegisterDevStatusCallback(callback));
50     ASSERT_NO_THROW(deviceObserver->OnDeviceOnline(devId, devName, deviceType));
51     ASSERT_NO_THROW(deviceObserver->OnDeviceOffline(devId, devName, deviceType));
52 }
53 
54 } // namespace Telephony
55 } // namespace OHOS