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.fixture; 17 18 import ohos.devtools.datasources.databases.databaseapi.DataBaseApi; 19 import ohos.devtools.datasources.utils.device.service.MultiDeviceManager; 20 import ohos.devtools.datasources.utils.plugin.IPluginConfig; 21 import ohos.devtools.datasources.utils.plugin.service.PlugManager; 22 import ohos.devtools.datasources.utils.process.service.ProcessManager; 23 import ohos.devtools.datasources.utils.profilerlog.ProfilerLogManager; 24 import ohos.devtools.datasources.utils.session.service.SessionManager; 25 import ohos.devtools.pluginconfig.AgentConfig; 26 import ohos.devtools.pluginconfig.BytraceConfig; 27 import ohos.devtools.pluginconfig.CpuConfig; 28 import ohos.devtools.pluginconfig.DiskIoConfig; 29 import ohos.devtools.pluginconfig.FtraceConfig; 30 import ohos.devtools.pluginconfig.HilogConfig; 31 import ohos.devtools.pluginconfig.MemoryConfig; 32 import ohos.devtools.pluginconfig.ProcessConfig; 33 import ohos.devtools.pluginconfig.UserConfig; 34 import ohos.devtools.views.common.UtConstant; 35 import ohos.devtools.views.layout.HomePanel; 36 import ohos.devtools.views.user.UserManager; 37 import org.apache.logging.log4j.Level; 38 import org.assertj.swing.fixture.FrameFixture; 39 import org.junit.After; 40 import org.junit.Before; 41 import org.junit.Test; 42 43 import javax.swing.JFrame; 44 import java.awt.AWTException; 45 import java.util.ArrayList; 46 import java.util.List; 47 import java.util.Objects; 48 import java.util.concurrent.TimeUnit; 49 50 /** 51 * Info And Stats Fixture Test 52 * 53 * @since 2021/2/1 9:31 54 */ 55 public class InfoAndStatsFixtureTest { 56 private FrameFixture frameFixture; 57 58 /** 59 * init 60 * 61 * @tc.name: init 62 * @tc.number: OHOS_JAVA_init_0001 63 * @tc.desc: init 64 * @tc.type: functional testing 65 * @tc.require: AR000FK5UI 66 * @throws AWTException AWTException 67 */ 68 @Before init()69 public void init() throws AWTException { 70 // Initialization data 71 ProcessManager.getInstance().setIsRequest(false); 72 SessionManager.getInstance().settingPermissions(); 73 ProfilerLogManager.getSingleton().updateLogLevel(Level.ERROR); 74 PlugManager.getInstance().unzipStdDevelopTools(); 75 DataBaseApi.getInstance().initDataSourceManager(); 76 MultiDeviceManager.getInstance().start(); 77 List<Class<? extends IPluginConfig>> plugConfigList = new ArrayList(); 78 plugConfigList.add(ProcessConfig.class); 79 plugConfigList.add(AgentConfig.class); 80 plugConfigList.add(BytraceConfig.class); 81 plugConfigList.add(FtraceConfig.class); 82 plugConfigList.add(CpuConfig.class); 83 plugConfigList.add(HilogConfig.class); 84 if (Objects.nonNull(UserManager.getInstance().getSdkImpl())) { 85 plugConfigList.add(UserConfig.class); 86 } 87 plugConfigList.add(DiskIoConfig.class); 88 plugConfigList.add(MemoryConfig.class); 89 PlugManager.getInstance().loadingPlugs(plugConfigList); 90 while (true) { 91 if (MultiDeviceManager.getInstance().getOnlineDeviceInfoList().size() > 0) { 92 break; 93 } 94 } 95 JFrame frame = new JFrame(); 96 frame.add(new HomePanel()); 97 frameFixture = new FrameFixture(frame); 98 // Display the frame 99 frameFixture.show(); 100 } 101 102 /** 103 * Info And Stats Test 104 * 105 * @tc.name: infoAndStatsTest 106 * @tc.number: OHOS_JAVA_infoAndStatsTest_0001 107 * @tc.desc: Info And Stats Test 108 * @tc.type: functional testing 109 * @tc.require: AR000FK5UI 110 * @throws InterruptedException InterruptedException 111 */ 112 @Test infoAndStatsTest()113 public void infoAndStatsTest() throws InterruptedException { 114 frameFixture.label(UtConstant.UT_WELCOME_PANEL_NEW_TASK_BTN).click(); 115 frameFixture.label(UtConstant.UT_TASK_PANEL_SYSTEM).click(); 116 frameFixture.button(UtConstant.UT_TASK_PANEL_CHOOSE).click(); 117 frameFixture.label(UtConstant.UT_SYSTEM_TUNING_LABEL).click(); 118 frameFixture.checkBox(UtConstant.UT_SYSTEM_TUNING_CATEGORIES).click(); 119 frameFixture.button(UtConstant.UT_TASK_SCENE_PANE_START).click(); 120 TimeUnit.SECONDS.sleep(20); 121 frameFixture.button(UtConstant.UT_SYSTEM_TUNING_INFO).click(); 122 TimeUnit.SECONDS.sleep(5); 123 frameFixture.panel(UtConstant.UT_TASK_PANEL_CLOSE).click(); 124 SessionManager.getInstance().stopAllSession(); 125 TimeUnit.SECONDS.sleep(6); 126 } 127 128 /** 129 * tear Down 130 * 131 * @tc.name: tearDown 132 * @tc.number: OHOS_JAVA_tearDown_0001 133 * @tc.desc: tear Down 134 * @tc.type: test Window 135 * @tc.require: AR000FK5UI 136 */ 137 @After tearDown()138 public void tearDown() { 139 frameFixture.cleanUp(); 140 } 141 } 142