-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplacecolor_test.cpp
More file actions
56 lines (41 loc) · 1.6 KB
/
replacecolor_test.cpp
File metadata and controls
56 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "colorpickerplugin.h"
#include "colorpickerplugin_p.h"
// Qt includes
#include <QAction>
#include <QtTest>
// QtCreator includes
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <texteditor/texteditor.h>
// Plugin includes
#include "colormodifier.h"
#include "colorpickerconstants.h"
#include "colorwatcher.h"
using namespace Core;
using namespace TextEditor;
namespace ColorPicker {
namespace Internal {
void ColorPickerPlugin::test_addAndReplaceColor()
{
QString fileName = QString::fromLatin1("test_ColorPickerPlugin_addAndReplaceColor.txt");
QFile file(fileName);
QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Text));
IEditor *currentEditor = EditorManager::instance()->openEditor(fileName);
QVERIFY(currentEditor);
TextEditorWidget *editorWidget = qobject_cast<TextEditorWidget *>(currentEditor->widget());
QVERIFY(editorWidget);
Command *colorEditCommand = ActionManager::command(Constants::TRIGGER_COLOR_EDIT);
QString color = QString::fromLatin1("rgb(12, 20, 40)");
editorWidget->appendPlainText(color);
QMap<ColorFormat, QColor> colors;
colors.insert(ColorFormat::QCssRgbUCharFormat, QColor(32, 18, 26));
colors.insert(ColorFormat::QssHsvFormat, QColor(32, 18, 26));
colors.insert(ColorFormat::HexFormat, QColor(32, 18, 26));
for (auto it = colors.begin(); it != colors.end(); ++it) {
d->colorModifier->insertColor(it.value(), it.key());
colorEditCommand->action()->trigger();
}
file.close();
}
} // namespace Internal
} // namespace ColorPicker