1package com.android.mail.utils; 2 3import android.test.AndroidTestCase; 4import android.test.suitebuilder.annotation.SmallTest; 5 6/** 7 * These test cases verify that the HTML email body is transformed correctly to support toggling 8 * the visibility of quoted text. 9 */ 10@SmallTest 11public class QuotedHtmlSanitizerTest extends AndroidTestCase { 12 /** 13 * Random garbage in a class attribute of a div is stripped. 14 */ 15 public void testGarbageDiv() { 16 // any random class value is disallowed 17 sanitize("<div class=\"garbage\"></div>", "<div></div>"); 18 } 19 20 /** 21 * For Gmail, <div class="gmail_quote"> indicates the block of quoted text. 22 */ 23 public void testGmailQuotedTextDiv() { 24 sanitize("<div class=\"gmail_quote\"></div>", "<div class=\"elided-text\"></div>"); 25 } 26 27 /** 28 * For Yahoo, <div class="yahoo_quoted"> indicates the block of quoted text. 29 */ 30 public void testYahooQuotedTextDiv() { 31 sanitize("<div class=\"yahoo_quoted\"></div>", "<div class=\"elided-text\"></div>"); 32 } 33 34 /** 35 * For AOL, <div id="AOLMsgPart_RANDOM_GUID"> indicates the block of quoted text. 36 */ 37 public void testAOLQuotedTextDiv() { 38 sanitize("<div id=\"AOLMsgPart_1_59da800c-ba5d-45c5-9ff7-29a8264a5bd9\"></div>", 39 "<div class=\"elided-text\"></div>"); 40 sanitize("<div id=\"AOLMsgPart_1_b916b4c7-3047-43a9-b24d-83b7ffd2b9b7\"></div>", 41 "<div class=\"elided-text\"></div>"); 42 } 43 44 private void sanitize(String dirtyHTML, String expectedHTML) { 45 final String cleansedHTML = HtmlSanitizer.sanitizeHtml(dirtyHTML); 46 assertEquals(expectedHTML, cleansedHTML); 47 } 48} 49