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.CpuConfig; 26 import ohos.devtools.pluginconfig.DiskIoConfig; 27 import ohos.devtools.pluginconfig.MemoryConfig; 28 import ohos.devtools.views.common.UtConstant; 29 import ohos.devtools.views.layout.HomePanel; 30 import org.apache.logging.log4j.Level; 31 import org.assertj.swing.fixture.FrameFixture; 32 import org.junit.After; 33 import org.junit.Before; 34 import org.junit.Test; 35 36 import javax.swing.JFrame; 37 import java.awt.AWTException; 38 import java.util.ArrayList; 39 import java.util.List; 40 import java.util.concurrent.TimeUnit; 41 42 /** 43 * Rate Regulation 44 * 45 * @since 2021/2/1 9:31 46 */ 47 public class RateRegulationFixtureTest { 48 private FrameFixture frameFixture; 49 50 /** 51 * init 52 * 53 * @tc.name: init 54 * @tc.number: OHOS_JAVA_init_0001 55 * @tc.desc: init 56 * @tc.type: functional testing 57 * @tc.require: AR000FK5UI 58 * @throws AWTException AWTException 59 */ 60 @Before init()61 public void init() throws AWTException { 62 // Initialization data 63 ProcessManager.getInstance().setIsRequest(false); 64 ProfilerLogManager.getSingleton().updateLogLevel(Level.ERROR); 65 DataBaseApi apo = DataBaseApi.getInstance(); 66 apo.initDataSourceManager(); 67 // Boot device 68 MultiDeviceManager.getInstance().start(); 69 List<Class<? extends IPluginConfig>> plugConfigList = new ArrayList(); 70 plugConfigList.add(CpuConfig.class); 71 plugConfigList.add(DiskIoConfig.class); 72 plugConfigList.add(MemoryConfig.class); 73 PlugManager.getInstance().loadingPlugs(plugConfigList); 74 while (true) { 75 if (MultiDeviceManager.getInstance().getOnlineDeviceInfoList().size() > 0) { 76 break; 77 } 78 } 79 JFrame frame = new JFrame(); 80 frame.add(new HomePanel()); 81 frameFixture = new FrameFixture(frame); 82 // Display the frame 83 frameFixture.show(); 84 } 85 86 /** 87 * test Window 88 * 89 * @tc.name: testWindow 90 * @tc.number: OHOS_JAVA_testWindow_0001 91 * @tc.desc: test Window 92 * @tc.type: test Window 93 * @tc.require: AR000FK5UI 94 * @throws InterruptedException InterruptedException 95 */ 96 @Test testWindow()97 public void testWindow() throws InterruptedException { 98 frameFixture.label(UtConstant.UT_WELCOME_PANEL_NEW_TASK_BTN).click(); 99 frameFixture.label(UtConstant.UT_TASK_PANEL_APPLICATION).click(); 100 frameFixture.button(UtConstant.UT_TASK_PANEL_CHOOSE).requireText(UtConstant.UT_TASK_PANEL_CHOOSE); 101 frameFixture.button(UtConstant.UT_TASK_PANEL_CHOOSE).click(); 102 TimeUnit.SECONDS.sleep(5); 103 frameFixture.button(UtConstant.UT_TASK_SCENE_PANE_START).click(); 104 TimeUnit.SECONDS.sleep(5); 105 frameFixture.comboBox(UtConstant.UT_TASK_SCENE_PANEL_CHART_TIME).click(); 106 frameFixture.comboBox(UtConstant.UT_TASK_SCENE_PANEL_CHART_TIME).selectItem(0); 107 TimeUnit.SECONDS.sleep(5); 108 // Close the main interface 109 frameFixture.panel(UtConstant.UT_TASK_PANEL_CLOSE).click(); 110 SessionManager.getInstance().stopAllSession(); 111 } 112 113 /** 114 * tear Down 115 * 116 * @tc.name: tearDown 117 * @tc.number: OHOS_JAVA_tearDown_0001 118 * @tc.desc: tear Down 119 * @tc.type: test Window 120 * @tc.require: AR000FK5UI 121 */ 122 @After tearDown()123 public void tearDown() { 124 frameFixture.close(); 125 frameFixture.cleanUp(); 126 } 127 } 128