Skip to content

Commit fa049a6

Browse files
ci: created Test class and fill it with basic functional
1 parent 023a056 commit fa049a6

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*******************************************************************************
2+
* Copyright 2021 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
3+
* Use is subject to license terms.
4+
*******************************************************************************/
5+
package com.espressif.idf.ui.test.executable.cases.project;
6+
7+
import java.io.IOException;
8+
9+
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
10+
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
11+
import org.junit.After;
12+
import org.junit.BeforeClass;
13+
import org.junit.FixMethodOrder;
14+
import org.junit.Test;
15+
import org.junit.runner.RunWith;
16+
import org.junit.runners.MethodSorters;
17+
18+
import com.espressif.idf.ui.test.common.WorkBenchSWTBot;
19+
import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
20+
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
21+
import com.espressif.idf.ui.test.operations.ProjectTestOperations;
22+
23+
/**
24+
* Test class to test the Flash process
25+
*
26+
* @author Andrii Filippov
27+
*
28+
*/
29+
@SuppressWarnings("restriction")
30+
@RunWith(SWTBotJunit4ClassRunner.class)
31+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
32+
33+
public class NewEspressifIDFProjectFlashProcessTest {
34+
@BeforeClass
35+
public static void beforeTestClass() throws Exception
36+
{
37+
Fixture.loadEnv();
38+
}
39+
40+
@After
41+
public void afterEachTest()
42+
{
43+
try
44+
{
45+
Fixture.cleanTestEnv(); // Make sure test environment is always cleaned up
46+
}
47+
catch (Exception e)
48+
{
49+
System.err.println("Error during cleanup: " + e.getMessage());
50+
}
51+
}
52+
53+
54+
@Test
55+
public void givenNewProjectCreatedBuiltWhenSelectSerialPortWhenFlashThenCheckFlashedSuccessfully()
56+
throws Exception
57+
{
58+
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
59+
Fixture.givenProjectNameIs("NewProjectFlashTest");
60+
Fixture.whenNewProjectIsSelected();
61+
Fixture.whenProjectIsBuiltUsingContextMenu();
62+
}
63+
64+
private static class Fixture
65+
{
66+
private static SWTWorkbenchBot bot;
67+
private static String category;
68+
private static String subCategory;
69+
private static String projectName;
70+
71+
private static void loadEnv() throws Exception
72+
{
73+
bot = WorkBenchSWTBot.getBot();
74+
EnvSetupOperations.setupEspressifEnv(bot);
75+
bot.sleep(1000);
76+
}
77+
78+
private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory)
79+
{
80+
Fixture.category = category;
81+
Fixture.subCategory = subCategory;
82+
}
83+
84+
private static void givenProjectNameIs(String projectName)
85+
{
86+
Fixture.projectName = projectName;
87+
}
88+
89+
private static void whenNewProjectIsSelected() throws Exception
90+
{
91+
ProjectTestOperations.setupProject(projectName, category, subCategory, bot);
92+
}
93+
94+
private static void whenProjectIsBuiltUsingContextMenu() throws IOException
95+
{
96+
ProjectTestOperations.buildProjectUsingContextMenu(projectName, bot);
97+
ProjectTestOperations.waitForProjectBuild(bot);
98+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
99+
}
100+
101+
private static void cleanTestEnv()
102+
{
103+
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
104+
ProjectTestOperations.closeAllProjects(bot);
105+
ProjectTestOperations.deleteAllProjects(bot);
106+
}
107+
}
108+
}

0 commit comments

Comments
 (0)