Initial version of Windows defender checker notification
[idea/community.git] / platform / diff-impl / tests / testSrc / com / intellij / diff / painting / DiffEditorPaintingTest.kt
1 // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2 package com.intellij.diff.painting
3
4 import com.intellij.diff.util.DiffDrawUtil
5 import com.intellij.diff.util.TextDiffType
6 import com.intellij.openapi.editor.Editor
7 import com.intellij.openapi.editor.EditorPaintingTestCase
8 import com.intellij.openapi.editor.markup.SeparatorPlacement
9 import com.intellij.testFramework.TestDataPath
10 import java.awt.Color
11
12 @TestDataPath("\$CONTENT_ROOT/testData/diff/painting")
13 class DiffEditorPaintingTest : EditorPaintingTestCase() {
14   override fun getTestDataPath(): String {
15     return "platform/diff-impl/tests/testData/diff/painting"
16   }
17
18   fun testWholeLineChanged() {
19     initText("foo")
20     DiffDrawUtil.createHighlighter(myEditor, 0, 1, MyDiffType, false)
21     checkResultWithGutter()
22   }
23
24   fun testOneLetterChanged() {
25     initText("foo")
26     DiffDrawUtil.createHighlighter(myEditor, 0, 1, MyDiffType, true)
27     DiffDrawUtil.createInlineHighlighter(myEditor, 1, 2, MyDiffType)
28     checkResultWithGutter()
29   }
30
31   fun testNewlineChanged() {
32     initText("fo\nbar")
33     DiffDrawUtil.createHighlighter(myEditor, 0, 2, MyDiffType, true)
34     DiffDrawUtil.createInlineHighlighter(myEditor, 2, 3, MyDiffType)
35     checkResultWithGutter()
36   }
37
38   fun testLastLineChanged() {
39     initText("foo\nx")
40     DiffDrawUtil.createHighlighter(myEditor, 1, 2, MyDiffType, false)
41     checkResultWithGutter()
42   }
43
44   fun testLastEmptyLineChanged() {
45     initText("foo\n")
46     DiffDrawUtil.createHighlighter(myEditor, 1, 2, MyDiffType, false)
47     checkResultWithGutter()
48   }
49
50   fun testLastLineSoftWraps() {
51     initText("foo ba biz")
52     configureSoftWraps(4);
53     DiffDrawUtil.createHighlighter(myEditor, 0, 1, MyDiffType, false)
54     checkResultWithGutter()
55   }
56
57   fun testEmptyRange() {
58     initText("foo\nbar")
59     DiffDrawUtil.createHighlighter(myEditor, 1, 1, MyDiffType, false)
60     checkResultWithGutter()
61   }
62
63   fun testEmptyRangeLastEmptyLine() {
64     initText("foo")
65     DiffDrawUtil.createHighlighter(myEditor, 1, 1, MyDiffType, false)
66     checkResultWithGutter()
67   }
68
69   fun testEmptyRangeLastLineSoftWraps() {
70     initText("foo ba biz")
71     configureSoftWraps(4);
72     DiffDrawUtil.createHighlighter(myEditor, 1, 1, MyDiffType, false)
73     checkResultWithGutter()
74   }
75
76   fun testLineMarker() {
77     initText("fo o\nba r")
78     configureSoftWraps(2);
79
80     DiffDrawUtil.createLineMarker(myEditor, 1, MyDiffType)
81     checkResultWithGutter()
82   }
83
84   fun testBorderLineMarker() {
85     initText("fo o\nba r")
86     configureSoftWraps(2);
87
88     DiffDrawUtil.createBorderLineMarker(myEditor, 1, SeparatorPlacement.BOTTOM)
89     DiffDrawUtil.createBorderLineMarker(myEditor, 1, SeparatorPlacement.TOP)
90     checkResultWithGutter()
91   }
92
93   private object MyDiffType : TextDiffType {
94     override fun getName(): String = throw UnsupportedOperationException()
95     override fun getColor(editor: Editor?): Color = Color.RED
96     override fun getIgnoredColor(editor: Editor?): Color = Color.BLUE
97     override fun getMarkerColor(editor: Editor?): Color? = Color.GREEN
98   }
99 }
100