-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test implementation for C/C++ devfile
Signed-off-by: Tibor Dancs <tdancs@redhat.com>
- Loading branch information
Showing
1 changed file
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2020 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
import 'reflect-metadata'; | ||
import * as projectAndFileTests from '../../testsLibrary/ProjectAndFileTests'; | ||
import * as workspaceHandling from '../../testsLibrary/WorksapceHandlingTests'; | ||
import * as commonLsTests from '../../testsLibrary/LsTests'; | ||
import * as codeExecutionTests from '../../testsLibrary/CodeExecutionTests'; | ||
import { e2eContainer } from '../../inversify.config'; | ||
import { WorkspaceNameHandler, Editor, CLASSES } from '../..'; | ||
import { Key } from 'selenium-webdriver'; | ||
|
||
const editor: Editor = e2eContainer.get(CLASSES.Editor); | ||
|
||
const workspaceSampleName: string = 'cpp-hello-world'; | ||
const fileFolderPath: string = `${workspaceSampleName}`; | ||
const tabTitle: string = 'hello.cpp'; | ||
const buildTaskName: string = 'build'; | ||
const runTaskName: string = 'run'; | ||
const stack: string = 'C/C++'; | ||
|
||
suite(`${stack} test`, async () => { | ||
suite (`Create ${stack} workspace`, async () => { | ||
workspaceHandling.createAndOpenWorkspace(stack); | ||
projectAndFileTests.waitWorkspaceReadinessNoSubfolder(workspaceSampleName); | ||
}); | ||
|
||
suite('Test opening file', async () => { | ||
// opening file that soon should give time for LS to initialize | ||
projectAndFileTests.openFile(fileFolderPath, tabTitle); | ||
prepareEditorForLSTests(); | ||
}); | ||
|
||
suite('Validation of project build', async () => { | ||
codeExecutionTests.runTask(buildTaskName, 30_000); | ||
codeExecutionTests.runTask(runTaskName, 30_000); | ||
}); | ||
|
||
suite('Language server validation', async () => { | ||
commonLsTests.errorHighlighting(tabTitle, `error_text;`, 12); | ||
commonLsTests.suggestionInvoking(tabTitle, 15, 22, 'test'); | ||
commonLsTests.autocomplete(tabTitle, 15, 9, 'printf'); | ||
commonLsTests.codeNavigationGoTo(tabTitle, 15, 9, 'stdio.h', Key.chord(Key.CONTROL, Key.F11)); | ||
}); | ||
|
||
suite ('Stopping and deleting the workspace', async () => { | ||
let workspaceName = 'not defined'; | ||
suiteSetup( async () => { | ||
workspaceName = await WorkspaceNameHandler.getNameFromUrl(); | ||
}); | ||
test (`Stop worksapce`, async () => { | ||
await workspaceHandling.stopWorkspace(workspaceName); | ||
}); | ||
test (`Remove workspace`, async () => { | ||
await workspaceHandling.removeWorkspace(workspaceName); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
export function prepareEditorForLSTests() { | ||
test(`Prepare file for LS tests`, async () => { | ||
await editor.moveCursorToLineAndChar(tabTitle, 6, 1); | ||
await editor.performKeyCombination(tabTitle, '#include <cstdio>\n'); | ||
await editor.moveCursorToLineAndChar(tabTitle, 10, 1); | ||
await editor.performKeyCombination(tabTitle, '\nchar const *test = "test";\n'); | ||
await editor.moveCursorToLineAndChar(tabTitle, 15, 5); | ||
await editor.performKeyCombination(tabTitle, 'printf("%s\\n", test);\n'); | ||
}); | ||
} |