• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
18 #include "broadcast_manager.h"
19 
20 namespace OHOS {
21 namespace NetManagerStandard {
22 namespace {
23 using namespace testing::ext;
24 BroadcastInfo g_testInfo;
25 } // namespace
26 
27 class BroadcastManagerTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp();
32     void TearDown();
33 };
34 
SetUpTestCase()35 void BroadcastManagerTest::SetUpTestCase()
36 {
37     g_testInfo.action = "testAction";
38     g_testInfo.data = "testData";
39 }
40 
TearDownTestCase()41 void BroadcastManagerTest::TearDownTestCase() {}
42 
SetUp()43 void BroadcastManagerTest::SetUp() {}
44 
TearDown()45 void BroadcastManagerTest::TearDown() {}
46 
47 HWTEST_F(BroadcastManagerTest, SendBroadcastTest001, TestSize.Level1)
48 {
49     std::map<std::string, bool> params = {{"test1", true}, {"test2", false}, {"test3", false}};
50     bool ret = DelayedSingleton<BroadcastManager>::GetInstance()->SendBroadcast(g_testInfo, params);
51     EXPECT_TRUE(ret);
52 }
53 
54 HWTEST_F(BroadcastManagerTest, SendBroadcastTest002, TestSize.Level1)
55 {
56     std::map<std::string, int32_t> params = {{"test1", 1}, {"test2", 2}, {"test3", 3}};
57     bool ret = DelayedSingleton<BroadcastManager>::GetInstance()->SendBroadcast(g_testInfo, params);
58     EXPECT_TRUE(ret);
59 }
60 
61 HWTEST_F(BroadcastManagerTest, SendBroadcastTest003, TestSize.Level1)
62 {
63     std::map<std::string, std::string> params = {{"test1", "testMsg1"}, {"test2", "testMsg2"}, {"test3", "testMsg3"}};
64     bool ret = DelayedSingleton<BroadcastManager>::GetInstance()->SendBroadcast(g_testInfo, params);
65     EXPECT_TRUE(ret);
66 }
67 } // namespace NetManagerStandard
68 } // namespace OHOS