Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit d931286

Browse files
committed
test: add e2e test for color pickers
1 parent c89138e commit d931286

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

python/tests/assets/qss/QLabel.qss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* for color provider test */
22

3-
QLabel { border-color: #ffa600 }
3+
QLabel { border-color: #ffff00 }
44

5-
QLabel { border-color: #7aff00d4 }
5+
QLabel { border-color: #ffffff00 }
66

7-
QLabel { border-color: #f00 }
7+
QLabel { border-color: #ff0 }
88

99
QLabel { border-color: rgb(100%, 100%, 0%)}
1010

1111
QLabel { border-color: rgb(255, 255, 0%)}
1212

13-
QLabel { border-color: rgba(255, 255, 0%, 100)}
13+
QLabel { border-color: rgba(255, 255, 0%, 100%)}
1414

1515
QLabel { border-color: hsv(60, 255, 100%)}
1616

17-
QLabel { border-color: hsva(60, 255, 100%, 100)}
17+
QLabel { border-color: hsva(60, 255, 100%, 100%)}
1818

1919
QLabel { border-color: hsl(60, 100%, 50%) }
2020

21-
QLabel { border-color: hsla(60, 100%, 50%, 100) }
21+
QLabel { border-color: hsla(60, 100%, 50%, 100%) }

src/test/suite/qss/e2e.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as assert from 'node:assert'
2+
import * as path from 'node:path'
3+
import type { ColorInformation, TextDocument } from 'vscode'
4+
import { commands, window, workspace } from 'vscode'
5+
import { URI } from 'vscode-uri'
6+
import { E2E_TIMEOUT, TEST_ASSETS_PATH } from '../test-utils'
7+
8+
suite('qss/e2e', () => {
9+
suite('color picker', () => {
10+
suite('when open QLabel.qss', () => {
11+
let document: TextDocument
12+
13+
suiteSetup(async function () {
14+
this.timeout(E2E_TIMEOUT)
15+
16+
document = await openAndShowTestQssFile('QLabel.qss')
17+
})
18+
19+
test('should contain color info', async () => {
20+
const colorInformationList: ColorInformation[] =
21+
await commands.executeCommand(
22+
'vscode.executeDocumentColorProvider',
23+
document.uri,
24+
)
25+
26+
assert.ok(colorInformationList.length > 0)
27+
colorInformationList.forEach(i => {
28+
assert.strictEqual(i.color.red, 1)
29+
assert.strictEqual(i.color.green, 1)
30+
assert.strictEqual(i.color.blue, 0)
31+
assert.strictEqual(i.color.alpha, 1)
32+
})
33+
}).timeout(E2E_TIMEOUT)
34+
}).timeout(E2E_TIMEOUT)
35+
}).timeout(E2E_TIMEOUT)
36+
}).timeout(E2E_TIMEOUT)
37+
38+
async function openAndShowTestQssFile(fileName: string) {
39+
const document = await workspace.openTextDocument(
40+
URI.file(path.resolve(TEST_ASSETS_PATH, 'qss', fileName)),
41+
)
42+
await window.showTextDocument(document)
43+
return document
44+
}

0 commit comments

Comments
 (0)