format multiline notifications in event log (IDEA-80305)
[idea/community.git] / platform / platform-tests / testSrc / com / intellij / notification / EventLogTest.groovy
index f0ac1b26be4c0ded1f3366ef9b9b32815f4b2f9b..896cf802fa0315a234d457d9e6e230dacfcbce82 100644 (file)
  */
 package com.intellij.notification;
 
-import com.intellij.testFramework.UsefulTestCase;
+
+import com.intellij.openapi.util.TextRange
+import com.intellij.testFramework.LightPlatformTestCase
+import com.intellij.testFramework.PlatformTestCase
 
 /**
  * @author peter
  */
-class EventLogTest extends UsefulTestCase {
+class EventLogTest extends LightPlatformTestCase {
+
+  EventLogTest() {
+    PlatformTestCase.initPlatformLangPrefix()
+  }
 
   public void testNbsp() {
     def entry = EventLog.formatForLog(new Notification("xxx", "Title", "Hello world", NotificationType.ERROR))
     assert entry.message == 'Title: Hello world'
   }
 
+  public void testParseMultilineText() {
+    def entry = EventLog.formatForLog(new Notification("xxx", "Title", "<html><body> " +
+                                                                       "<font size=\"3\">first line<br>" +
+                                                                       "second line<br>" +
+                                                                       "third<br>" +
+                                                                       "<a href=\"create\">Action</a><br>" +
+                                                                       "</body></html>", NotificationType.ERROR))
+    assert entry.message == 'Title:  first line second line third // Action (show balloon)'
+    //                       0                                       40      48          60
+    assert entry.links.collect { it.first } == [new TextRange(40, 46), new TextRange(48, 60)]
+
+  }
+
+  public void testInParagraph() {
+    def entry = EventLog.formatForLog(new Notification("xxx", "Title", "<p>message</p>", NotificationType.ERROR))
+    assert entry.message == 'Title: message'
+  }
+
+  public void testJavaSeparators() {
+    def entry = EventLog.formatForLog(new Notification("xxx", "Title", "fst\nsnd", NotificationType.ERROR))
+    assert entry.message == 'Title: fst snd'
+  }
+
 }