Skip to content

Commit

Permalink
Improve TC defined in XML API
Browse files Browse the repository at this point in the history
  • Loading branch information
Hung-LeThai committed Apr 18, 2023
1 parent 91a0ca4 commit 15f42f3
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 63 deletions.
6 changes: 6 additions & 0 deletions swtbot_test/src/model/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class Application {
private String appId;
private int appOrder;
private boolean skipApp = false;
private Collection<Language> languages = new ArrayList<>();
private Collection<ProjectConfiguration> configuration = new ArrayList<>();
private Collection<Target> targets = new ArrayList<>();
Expand Down Expand Up @@ -46,8 +47,13 @@ public int getApplicationOrder() {
return appOrder;
}

public boolean isSkipApp() {
return skipApp;
}

private void parseAttribute(Element element) {
appId = element.getAttribute("id");
skipApp = Boolean.parseBoolean(element.getAttribute("skipapp"));
try {
appOrder = Integer.parseInt(element.getAttribute("order"));
} catch (Exception e) {
Expand Down
12 changes: 6 additions & 6 deletions swtbot_test/src/model/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Project {
private String id;
private String projectName;
private Collection<GroupSetting> groupSettings = new ArrayList<>();
private Application app;
private Collection<Application> apps = new ArrayList<>();

public Project(Element element) {
parseAttribute(element);
Expand All @@ -26,7 +26,7 @@ public Project(Element element) {
} else if ("group".equalsIgnoreCase(name)) {
addGroupSetting(new GroupSetting(childElement));
} else if ("application".equalsIgnoreCase(name)) {
setApplication(new Application(childElement));
addApplication(new Application(childElement));
}
}
}
Expand Down Expand Up @@ -61,11 +61,11 @@ public GroupSetting getGroupSettingById(String id) {
return null;
}

private void setApplication(Application app) {
this.app = app;
private void addApplication(Application app) {
apps.add(app);
}

public Application getApp() {
return app;
public Collection<Application> getApps() {
return apps;
}
}
2 changes: 1 addition & 1 deletion swtbot_test/src/model/ProjectModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import parameters.ProjectParameters.BuildType;

public class ProjectModel {
private String language;
private String language = "C"; // default C project
private String familyName;
private String projectName;
private String toolchain;
Expand Down
30 changes: 26 additions & 4 deletions swtbot_test/src/testcase/CreateAllAzureProjectBuildAllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import java.io.File;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
Expand All @@ -22,18 +26,36 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CreateAllAzureProjectBuildAllTest {
private static SWTWorkbenchBot bot;
private static SWTBotShell workbenchShell;


@BeforeClass
public static void beforeClass() throws Exception {
bot = new SWTWorkbenchBot();
PlatformModel.loadPlatformModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.PLATFORM_XML_FILE)));
RTOSManager.loadRTOSModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.RTOS_PG_XML_FILE)));

// initialize the SWTBot
bot = new SWTWorkbenchBot();
Display.getDefault().syncExec(new Runnable() {

@Override
public void run() {
bot.getDisplay().getActiveShell().setMaximized(true);
}
});
SWTBotPreferences.TIMEOUT = 20000;
SWTBotPreferences.PLAYBACK_DELAY = 30;
closeWelcomePage();
workbenchShell = bot.activeShell();
}

@Test
public void TC_011_closeWelcome() throws Exception {
bot.viewByTitle("Welcome").close();
private static void closeWelcomePage() {
for (SWTBotView view : bot.views()) {
if (view.getTitle().equals("Welcome")) {
view.close();
}
}
}

@Test
Expand Down Expand Up @@ -123,7 +145,7 @@ public void TC_181_PG_Bootloader() throws Exception {

@Test
public void TC_191_BuildAll() throws Exception {
BuildUtility.buildAll();
BuildUtility.buildAll(workbenchShell);
}

}
11 changes: 1 addition & 10 deletions swtbot_test/src/testcase/TCExecute.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@

import common.Constants;
import common.LogUtil;
import model.ProjectModel;
import model.RTOSManager;
import model.TC;
import model.TCManager;
import parameters.ProjectParameters.RTOSApplication;
import parameters.ProjectParameters.RTOSType;
import parameters.ProjectParameters.RTOSVersion;
import parameters.ProjectParameters.TargetBoard;
import platform.PlatformModel;
import utilities.PGUtility;
import utilities.Utility;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TCExecute {
private static SWTWorkbenchBot bot;
private static SWTBotShell workbenchShell;
private static ProjectModel model;
private static Collection<TC> tces;

@BeforeClass
Expand All @@ -41,8 +34,6 @@ public static void beforeClass() throws Exception {
PlatformModel
.loadPlatformModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.PLATFORM_XML_FILE)));
RTOSManager.loadRTOSModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.RTOS_PG_XML_FILE)));
model = PGUtility.prepareProjectModel(RTOSType.AZURE, RTOSVersion.Azure_6_2_1, RTOSApplication.AZURE_IOT_ADU,
Constants.GCC_TOOLCHAIN, TargetBoard.BOARD_CK_RX65N);
TCManager.loadRTOSModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.TC_XML_FILE)));
tces = TCManager.getAllTCes();

Expand Down Expand Up @@ -74,7 +65,7 @@ public void TC_00_execute () throws ParseException {
workbenchShell.setFocus();
Utility.changeRTOSLocation();
for (TC tc : tces) {
Utility.executeTCStep(tc);
Utility.executeTCStep(tc, workbenchShell);
}
}
}
11 changes: 5 additions & 6 deletions swtbot_test/src/testcase/TrialTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testcase;

import java.io.File;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
Expand All @@ -14,7 +13,6 @@

import common.Constants;
import common.LogUtil;
import model.ProjectModel;
import model.RTOSManager;
import parameters.ProjectParameters.RTOSApplication;
import parameters.ProjectParameters.RTOSType;
Expand All @@ -28,16 +26,13 @@
public class TrialTest {
private static SWTWorkbenchBot bot;
private static SWTBotShell workbenchShell;
private static ProjectModel model;

@BeforeClass
public static void beforeClass() throws Exception {
// process the model xml
PlatformModel
.loadPlatformModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.PLATFORM_XML_FILE)));
RTOSManager.loadRTOSModel(new File(Utility.getBundlePath(LogUtil.PLUGIN_ID, Constants.RTOS_PG_XML_FILE)));
model = PGUtility.prepareProjectModel(RTOSType.AZURE, RTOSVersion.Azure_6_2_1, RTOSApplication.AZURE_IOT_ADU,
Constants.GCC_TOOLCHAIN, TargetBoard.BOARD_CK_RX65N);

// initialize the SWTBot
bot = new SWTWorkbenchBot();
Expand Down Expand Up @@ -66,6 +61,10 @@ private static void closeWelcomePage() {
public void TC_02_createProject() {
workbenchShell.setFocus();
Utility.changeRTOSLocation();
PGUtility.createProject(RTOSType.AZURE, RTOSVersion.Azure_6_2_1, RTOSApplication.AZURE_IOT_ADU);
PGUtility.createProject(RTOSType.AZURE, RTOSVersion.Azure_6_2_1, RTOSApplication.AZURE_BARE,
Constants.GCC_TOOLCHAIN, TargetBoard.BOARD_CK_RX65N);
workbenchShell.setFocus();
//build All
bot.menu(workbenchShell).menu("Project").menu("Build All").click();
}
}
10 changes: 3 additions & 7 deletions swtbot_test/src/utilities/BuildUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;

import common.Constants;
Expand Down Expand Up @@ -112,9 +110,7 @@ public static void deleteProject(ProjectModel model) {

}

public static void buildAll() throws ParseException {
bot.sleep(3000);
bot.shell().pressShortcut(Keystrokes.CTRL, Keystrokes.ALT, KeyStroke.getInstance("B"));
bot.sleep(3000);
public static void buildAll(SWTBotShell shell){
bot.menu(shell).menu("Project").menu("Build All").click();
}
}
33 changes: 16 additions & 17 deletions swtbot_test/src/utilities/PGUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,16 @@ public static Collection<ProjectModel> prepareProjectModel(TC tc) {
GroupSetting toolSetting = project.getGroupSettingById("toolchain");
GroupSetting deviceSetting = project.getGroupSettingById("device");
GroupSetting configSetting = project.getGroupSettingById("configuration");
if (toolSetting != null) {
for (Toolchain toolchain : toolSetting.getToolchains()) {
if (deviceSetting == null) {
continue;
}
for (Board board : deviceSetting.getBoards()) {
if (toolSetting == null) {
return results;
}
for (Toolchain toolchain : toolSetting.getToolchains()) {
if (deviceSetting == null) {
continue;
}
for (Board board : deviceSetting.getBoards()) {
for (Application app : project.getApps()) {
ProjectModel model = new ProjectModel();
if (deviceSetting.getBoards().size() == 1) {
model.setProjectName(project.getProjectName());
} else {
model.setProjectName(
project.getProjectName() + "_" + toolchain.getName() + "_" + getProjectNameByBoard(board.getBoard()));
}
if (toolSetting.getLanguage() != null) {
model.setLanguage(toolSetting.getLanguage().getId());
}
Expand All @@ -193,11 +190,13 @@ public static Collection<ProjectModel> prepareProjectModel(TC tc) {
} else {
model.setBuildType(BuildType.HARDWARE, true);
}
if (project.getApp() != null) {
model.setApplication(project.getApp().getApplicationId());
model.setApplicationOrder(project.getApp().getApplicationOrder());
model.setRXCLinkerFile(getRXCLinkerFile(project.getApp().getLinkerFiles(), toolchain.getName(), board.getBoard()));
}
model.setProjectName(app.getApplicationId() + "_" + toolchain.getName() + "_"
+ getProjectNameByBoard(board.getBoard()));
model.setApplication(app.getApplicationId());
model.setApplicationOrder(app.getApplicationOrder());
model.setSkipApplication(app.isSkipApp());
model.setRXCLinkerFile(
getRXCLinkerFile(app.getLinkerFiles(), toolchain.getName(), board.getBoard()));
results.add(model);
}
}
Expand Down
6 changes: 3 additions & 3 deletions swtbot_test/src/utilities/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public static void updateRXCLinkerSection(ProjectModel model, String rxcLinkerFi
dialogBot.waitUntil(Conditions.shellCloses(reDialog));
}

public static void executeTCStep(TC tc) throws ParseException {
public static void executeTCStep(TC tc, SWTBotShell shell) throws ParseException {
// create project or import project or using current project
Collection<ProjectModel> result = null;
for (Project project : tc.getProjects()) {
Expand Down Expand Up @@ -428,8 +428,8 @@ public int compare(Action o1, Action o2) {
Utility.changeBoard(model, null, null, true, false);
}
}
} else if (action.getActionId().equalsIgnoreCase("buildproject")) {
BuildUtility.buildAll();
} else if (action.getActionId().equalsIgnoreCase("buildAll")) {
BuildUtility.buildAll(shell);
}
}
}
Expand Down
32 changes: 23 additions & 9 deletions swtbot_test/xml/testcase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,38 @@
<testdata>
<TC id="TC1">
<project id="pg">
<projectname>adu</projectname>
<group id="toolchain">
<language id="C"></language>
<toolchain>GCC</toolchain>
<toolchain>CCRX</toolchain>
<!--toolchain>CCRX</toolchain-->
<RTOSType>AzureRTOS</RTOSType>
<RTOSVersion>6.2.1_rel-rx-1.0.0</RTOSVersion>
</group>
<group id="device">
<board>CK-RX65N</board>
<board>RSKRX65N-2MB</board>
<!--board>RSKRX65N-2MB</board>
<board>EnvisionKitRX72N</board-->
<board>CloudKitRX65N</board>
</group>
<group id="configuration">
<config id="HardwareDebug" active="true"/>
<application id="iot_sdk" order="4"></application>
<application id="iot_sdk_pnp" order="6"></application>
<application id="temp_pnp" order="8"></application>
</project>
</TC>
<TC id="TC2">
<project id="pg">
<group id="toolchain">
<toolchain>GCC</toolchain>
<!--toolchain>CCRX</toolchain-->
<RTOSType>AzureRTOS</RTOSType>
<RTOSVersion>6.2.1_rel-rx-1.0.0</RTOSVersion>
</group>
<group id="device">
<board>CK-RX65N</board>
</group>
<application id="iot_adu" order="16" skipapp="false"></application>
<application id="iot_sdk_ewf" order="5"></application>
<application id="iot_sdk_pnp_ewf" order="7"></application>
<application id="temp_pnp_ewf" order="9"></application>
</project>
<action id="changeboard" order="0"></action>
<action id="buildproject" order="1"></action>
<action id="buildAll" order="0"></action>
</TC>
</testdata>

0 comments on commit 15f42f3

Please sign in to comment.