1 /* 2 * Copyright (c) 2021 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 package ohos.devtools.views.hilog; 17 18 import com.intellij.ui.components.JBPanel; 19 import com.intellij.ui.components.JBTabbedPane; 20 import ohos.devtools.views.common.Constant; 21 import ohos.devtools.views.layout.WelcomePanel; 22 import org.junit.Assert; 23 import org.junit.Before; 24 import org.junit.Test; 25 26 import java.awt.BorderLayout; 27 import java.awt.GridLayout; 28 import java.awt.event.MouseEvent; 29 30 /** 31 * HiLog Panel Test 32 * 33 * @since 2021/2/1 9:31 34 */ 35 public class HiLogPanelTest { 36 private HiLogPanel hiLog; 37 38 /** 39 * init 40 * 41 * @tc.name: init 42 * @tc.number: OHOS_JAVA_View_HiLogPanel_init_0001 43 * @tc.desc: init 44 * @tc.type: functional testing 45 * @tc.require: AR000FK5UI 46 */ 47 @Before init()48 public void init() { 49 JBPanel containerPanel = new JBPanel(new GridLayout()); 50 WelcomePanel welcomePanel = new WelcomePanel(); 51 containerPanel.add(welcomePanel); 52 Constant.jtasksTab = new JBTabbedPane(); 53 hiLog = new HiLogPanel(containerPanel, welcomePanel); 54 } 55 56 /** 57 * HiLog Panel Test 58 * 59 * @tc.name: HiLogPanelTest 60 * @tc.number: OHOS_JAVA_View_HiLogPanel_HiLogPanelTest_0001 61 * @tc.desc: HiLog Panel Test 62 * @tc.type: functional testing 63 * @tc.require: AR000FK5UI 64 */ 65 @Test hiLogPanelTest()66 public void hiLogPanelTest() { 67 JBPanel jbPanel = new JBPanel(); 68 jbPanel.setLayout(new BorderLayout()); 69 JBPanel containerPanel = new JBPanel(new GridLayout()); 70 WelcomePanel welcomePanel = new WelcomePanel(); 71 containerPanel.add(welcomePanel); 72 jbPanel.add(containerPanel, BorderLayout.CENTER); 73 Constant.jtasksTab = new JBTabbedPane(); 74 HiLogPanel hiLogPanel = new HiLogPanel(containerPanel, welcomePanel); 75 Assert.assertNotNull(hiLogPanel); 76 } 77 78 /** 79 * mouse Clicked Test 80 * 81 * @tc.name: mouseClickedTest 82 * @tc.number: OHOS_JAVA_View_HiLogPanel_mouseClickedTest_0001 83 * @tc.desc: mouse Clicked Test 84 * @tc.type: functional testing 85 * @tc.require: AR000FK5UI 86 */ 87 @Test mouseClickedTest()88 public void mouseClickedTest() { 89 JBPanel jBPanel = new JBPanel(); 90 MouseEvent mouseEvent = new MouseEvent(jBPanel, 1, 1, 1, 1, 1, 1, true, 1); 91 mouseEvent.getComponent().setName("x"); 92 hiLog.mouseClicked(mouseEvent); 93 Assert.assertTrue(true); 94 } 95 }