• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
18 #include "window_inspector.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 class WindowInspetorTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void WindowInspetorTest::SetUpTestCase() {}
34 
TearDownTestCase()35 void WindowInspetorTest::TearDownTestCase() {}
36 
SetUp()37 void WindowInspetorTest::SetUp() {}
38 
TearDown()39 void WindowInspetorTest::TearDown() {}
40 
41 namespace {
42 /**
43  * @tc.name: InitConnectServer01
44  * @tc.desc: InitConnectServer
45  * @tc.type: FUNC
46  */
47 HWTEST_F(WindowInspetorTest, InitConnectServer, TestSize.Level1)
48 {
49     WindowInspector::GetInstance().ConnectServer();
50     EXPECT_EQ(true, WindowInspector::GetInstance().IsConnectServerSuccess());
51 }
52 
53 /**
54  * @tc.name: ProcessArkUIInspectorMessage01
55  * @tc.desc: ProcessArkUIInspectorMessage
56  * @tc.type: FUNC
57  */
58 HWTEST_F(WindowInspetorTest, ProcessArkUIInspectorMessage, TestSize.Level1)
59 {
60     std::string jsonStr;
61     std::string message1 = "{method:WMS,params:{interface:getCurrentProcessWindowList}}";
62     auto ret = WindowInspector::GetInstance().ProcessArkUIInspectorMessage(message1, jsonStr);
63     EXPECT_EQ(false, ret);
64 
65     std::string message2 = "{method:WMS.windowList,params:{interface:get}}";
66     ret = WindowInspector::GetInstance().ProcessArkUIInspectorMessage(message2, jsonStr);
67     EXPECT_EQ(false, ret);
68 
69     std::string message3 = "{method:WMS.windowList,params:{interface:getCurrentProcessWindowList}}";
70     ret = WindowInspector::GetInstance().ProcessArkUIInspectorMessage(message3, jsonStr);
71     EXPECT_EQ(false, ret);
72 
73     std::string message4 = R"({"method":30,"params":{"interface":"getCurrentProcessWindowList"}})";
74     ret = WindowInspector::GetInstance().ProcessArkUIInspectorMessage(message4, jsonStr);
75     EXPECT_EQ(false, ret);
76 
77     std::string message5 = R"({"method":"WMS.windowList","params":{"command":30}})";
78     ret = WindowInspector::GetInstance().ProcessArkUIInspectorMessage(message5, jsonStr);
79     EXPECT_EQ(false, ret);
80 }
81 } // namespace
82 } // namespace Rosen
83 } // namespace OHOS