• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.profilerlog.ProfilerLogManager;
23 import ohos.devtools.datasources.utils.session.service.SessionManager;
24 import ohos.devtools.pluginconfig.CpuConfig;
25 import ohos.devtools.pluginconfig.DiskIoConfig;
26 import ohos.devtools.pluginconfig.MemoryConfig;
27 import ohos.devtools.views.common.UtConstant;
28 import ohos.devtools.views.layout.HomePanel;
29 import org.apache.logging.log4j.Level;
30 import org.assertj.swing.fixture.FrameFixture;
31 import org.junit.After;
32 import org.junit.Assert;
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  * Memory ComboBox Fixture Test
44  *
45  * @since 2021/2/1 9:31
46  */
47 public class MemoryComboBoxFixtureTest {
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         ProfilerLogManager.getSingleton().updateLogLevel(Level.ERROR);
64         DataBaseApi apo = DataBaseApi.getInstance();
65         apo.initDataSourceManager();
66         // Boot device
67         MultiDeviceManager.getInstance().start();
68         List<Class<? extends IPluginConfig>> plugConfigList = new ArrayList();
69         plugConfigList.add(CpuConfig.class);
70         plugConfigList.add(DiskIoConfig.class);
71         plugConfigList.add(MemoryConfig.class);
72         PlugManager.getInstance().loadingPlugs(plugConfigList);
73         while (true) {
74             if (MultiDeviceManager.getInstance().getOnlineDeviceInfoList().size() > 0) {
75                 break;
76             }
77         }
78         JFrame frame = new JFrame();
79         frame.add(new HomePanel());
80         frameFixture = new FrameFixture(frame);
81         // Display the frame
82         frameFixture.show();
83     }
84 
85     /**
86      * test Window
87      *
88      * @tc.name: testWindow
89      * @tc.number: OHOS_JAVA_testWindow_0001
90      * @tc.desc: test Window
91      * @tc.type: test Window
92      * @tc.require: AR000FK5UI
93      * @throws InterruptedException InterruptedException
94      */
95     @Test
testWindow()96     public void testWindow() throws InterruptedException {
97         frameFixture.label(UtConstant.UT_WELCOME_PANEL_NEW_TASK_BTN).click();
98         frameFixture.label(UtConstant.UT_TASK_PANEL_APPLICATION).click();
99         frameFixture.button(UtConstant.UT_TASK_PANEL_CHOOSE).requireText(UtConstant.UT_TASK_PANEL_CHOOSE);
100         frameFixture.button(UtConstant.UT_TASK_PANEL_CHOOSE).click();
101         TimeUnit.SECONDS.sleep(5);
102         frameFixture.button(UtConstant.UT_TASK_SCENE_PANE_START).click();
103         TimeUnit.SECONDS.sleep(15);
104         // Graphic display Category display
105         frameFixture.label(UtConstant.UT_MEMORY_ITEM_VIEW_FOLD).click();
106         frameFixture.comboBox(UtConstant.UT_MEMORY_ITEM_VIEW_COLLECT_BOX).click();
107         frameFixture.comboBox(UtConstant.UT_MEMORY_ITEM_VIEW_COLLECT_BOX).selectItem(0);
108         String[] collectBox = frameFixture.comboBox(UtConstant.UT_MEMORY_ITEM_VIEW_COLLECT_BOX).contents();
109         Assert.assertEquals(collectBox[0], "Full");
110         TimeUnit.SECONDS.sleep(2);
111         // Close the main interface
112         frameFixture.panel(UtConstant.UT_TASK_PANEL_CLOSE).click();
113         SessionManager.getInstance().stopAllSession();
114     }
115 
116     /**
117      * tear Down
118      *
119      * @tc.name: tearDown
120      * @tc.number: OHOS_JAVA_tearDown_0001
121      * @tc.desc: tear Down
122      * @tc.type: test Window
123      * @tc.require: AR000FK5UI
124      */
125     @After
tearDown()126     public void tearDown() {
127         frameFixture.close();
128         frameFixture.cleanUp();
129     }
130 }
131