Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@

package com.espressif.idf.ui.test.executable.cases.project;

import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
import static org.junit.Assert.assertTrue;

import java.io.IOException;

import org.apache.commons.lang3.SystemUtils;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.espressif.idf.ui.test.common.WorkBenchSWTBot;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.*;
import static org.junit.Assert.assertTrue;

import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility;
import com.espressif.idf.ui.test.operations.EnvSetupOperations;
import com.espressif.idf.ui.test.operations.ProjectTestOperations;
Expand All @@ -38,31 +38,24 @@
@SuppressWarnings("restriction")
@RunWith(SWTBotJunit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class IDFProjectJTAGFlashTest
public class IDFProjectJTAGFlashTest
{
@BeforeClass
public static void beforeTestClass() throws Exception
{
Fixture.loadEnv();
}

@After
public void afterEachTest()
@AfterClass
public static void tearDown()
{
try
{
Fixture.cleanTestEnv();
}
catch (Exception e)
{
System.err.println("Error during cleanup: " + e.getMessage());
}
Fixture.cleanupEnvironment();
}

@Test
public void givenNewProjectCreatedWhenSelectJTAGflashWhenBuiltThenCheckFlashedSuccessfully() throws Exception
{
if (SystemUtils.IS_OS_LINUX) //temporary solution until new ESP boards arrive for Windows
if (SystemUtils.IS_OS_LINUX) // temporary solution until new ESP boards arrive for Windows
{
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("NewProjectJTAGFlashTest");
Expand Down Expand Up @@ -153,10 +146,11 @@ private static void whenSelectLaunchTargetBoard() throws Exception

private static void thenVerifyJTAGflashDone() throws Exception
{
ProjectTestOperations.verifyTheConsoleOutput(bot, "** Flashing done for partition_table/partition-table.bin");
ProjectTestOperations.verifyTheConsoleOutput(bot,
"** Flashing done for partition_table/partition-table.bin");
}

private static void cleanTestEnv()
private static void cleanupEnvironment()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,85 +36,57 @@
@RunWith(SWTBotJunit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)

public class IDFProjectLaunchTargetEditorFunctionalityTest {
public class IDFProjectLaunchTargetEditorFunctionalityTest
{

@BeforeClass
public static void beforeTestClass() throws Exception
{
Fixture.loadEnv();
Fixture.givenNewEspressifIDFProjectIsSelected("EspressIf", "Espressif IDF Project");
Fixture.givenProjectNameIs("LaunchTargetEditorTest");
Fixture.whenNewProjectIsSelected();
Fixture.createProject();
}

@AfterClass
public static void afterEachTest()
public static void tearDown()
{
try
{
Fixture.cleanTestEnv();
}
catch (Exception e)
{
System.err.println("Error during cleanup: " + e.getMessage());
}
Fixture.cleanupEnvironment();
}

@Test
public void givenANewProjectCreatedBuiltWhenSelectNewTargetWhenPopUpAppearsThenBuildFolderDeletedSuccessfully()
throws Exception
{
public void shouldDeleteBuildFolderWhenChangingLaunchTargetOnBuiltProject() throws Exception
{
Fixture.whenProjectIsBuiltUsingContextMenu();
Fixture.whenChangeLaunchTarget();
Fixture.whenRefreshProject();
Fixture.thenBuildFolderDeletedSuccessfully();
}

@Test
public void givenBNewProjectCreatedWhenCreateNewLaunchTargetThenProjectBuiltSuccessfully()
throws Exception
public void shouldBuildProjectWhenCreatingNewLaunchTargetAndDeleteItSuccessfully() throws Exception
{
Fixture.whenCreateNewLaunchTarget();
Fixture.whenProjectIsBuiltUsingContextMenu();
}

@Test
public void givenCNewProjectCreatedWhenDeleteSelectedLaunchTargetThenDeletedSuccessfully()
throws Exception
{
Fixture.whenProjectFullCleanUsingContextMenu();
Fixture.whenProjectFullCleaned();
Fixture.whenDeleteSelectedLaunchTarget();
Fixture.thenLaunchTargetDeletedSuccessfully();
}

private static class Fixture
{
private static SWTWorkbenchBot bot;
private static String category;
private static String subCategory;
private static String projectName;

private static void loadEnv() throws Exception
private static String projectName = "Project";

static void loadEnv() throws Exception
{
bot = WorkBenchSWTBot.getBot();
EnvSetupOperations.setupEspressifEnv(bot);
bot.sleep(1000);
ProjectTestOperations.deleteAllProjects(bot);
}

private static void givenNewEspressifIDFProjectIsSelected(String category, String subCategory)
{
Fixture.category = category;
Fixture.subCategory = subCategory;
}

private static void givenProjectNameIs(String projectName)
private static void createProject() throws Exception
{
Fixture.projectName = projectName;
}

private static void whenNewProjectIsSelected() throws Exception
{
ProjectTestOperations.setupProject(projectName, category, subCategory, bot);
ProjectTestOperations.setupProject(projectName, "EspressIf", "Espressif IDF Project", bot);
}

private static void whenProjectIsBuiltUsingContextMenu() throws IOException
Expand Down Expand Up @@ -148,7 +120,7 @@ private static void whenDeleteLaunchTarget() throws Exception
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 20000);
SWTBotShell shell = bot.shell("New ESP Target");
shell.setFocus();
bot.button("Delete").click();
bot.button("Delete").click();
}

private static void whenDeleteSelectedLaunchTarget() throws Exception
Expand Down Expand Up @@ -179,7 +151,7 @@ private static void handleNewLaunchTargetDialog() throws Exception
shell.setFocus();
bot.waitUntil(widgetIsEnabled(bot.button("Next >")), 5000);
bot.button("Next >").click();
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target",10000);
TestWidgetWaitUtility.waitForDialogToAppear(bot, "New ESP Target", 10000);
}

private static void handleNewEspTargetDialog() throws Exception
Expand All @@ -203,23 +175,28 @@ private static void whenRefreshProject() throws IOException

private static void thenBuildFolderDeletedSuccessfully() throws Exception
{
assertTrue("Build folder was not deleted successfully!", ProjectTestOperations.findProjectFullCleanedFilesInBuildFolder(projectName, bot));
assertTrue("Build folder was not deleted successfully!",
ProjectTestOperations.findProjectFullCleanedFilesInBuildFolder(projectName, bot));
}

private static void whenProjectFullCleanUsingContextMenu() throws IOException
private static void whenProjectFullCleaned() throws IOException
{
ProjectTestOperations.launchCommandUsingContextMenu(projectName, bot, "Project Full Clean");
ProjectTestOperations.joinJobByName(Messages.ProjectFullCleanCommandHandler_RunningFullcleanJobName);
ProjectTestOperations.findInConsole(bot, "Espressif IDF Tools Console", "Done");
TestWidgetWaitUtility.waitForOperationsInProgressToFinishSync(bot);

bot.tree().getTreeItem(projectName).getNode("sdkconfig").select();
bot.tree().getTreeItem(projectName).getNode("sdkconfig").contextMenu("Delete").click();
bot.shell("Delete Resources").bot().button("OK").click();
TestWidgetWaitUtility.waitWhileDialogIsVisible(bot, "Delete Resources", 10000);
}

private static void cleanTestEnv()
static void cleanupEnvironment()
{
TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot);
ProjectTestOperations.closeAllProjects(bot);
ProjectTestOperations.deleteAllProjects(bot);
}
}
}

Loading
Loading