1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt.internal.editors.layout.gle2; 18 19 import junit.framework.TestCase; 20 21 public class RenderLoggerTest extends TestCase { 22 public void testLogger1() throws Exception { 23 RenderLogger l = new RenderLogger("foo"); 24 assertFalse(l.hasProblems()); 25 } 26 27 public void testLogger2() throws Exception { 28 RenderLogger l = new RenderLogger("foo"); 29 assertFalse(l.hasProblems()); 30 l.fidelityWarning(null, "No perspective Transforms", null, null); 31 l.fidelityWarning(null, "No GPS", null, null); 32 assertTrue(l.hasProblems()); 33 assertEquals("The graphics preview in the layout editor may not be accurate:\n" 34 + "* No perspective Transforms\n" + "* No GPS\n", l.getProblems(true)); 35 assertFalse(l.seenTag("foo")); 36 assertFalse(l.seenTag(null)); 37 } 38 39 public void testLogger3() throws Exception { 40 RenderLogger l = new RenderLogger("foo"); 41 assertFalse(l.hasProblems()); 42 l.error("timeout", "Sample Error", new RuntimeException(), null); 43 l.warning("slow", "Sample warning", null); 44 assertTrue(l.hasProblems()); 45 assertEquals("Sample Error\n" + "Sample warning\n" 46 + "Exception details are logged in Window > Show View > Error Log", 47 l.getProblems(true)); 48 assertFalse(l.seenTag("foo")); 49 assertTrue(l.seenTag("timeout")); 50 assertTrue(l.seenTag("slow")); 51 assertFalse(l.seenTagPrefix("foo")); 52 assertTrue(l.seenTagPrefix("timeout")); 53 assertTrue(l.seenTagPrefix("slow")); 54 assertTrue(l.seenTagPrefix("time")); 55 assertFalse(l.seenTagPrefix("timeouts")); 56 } 57 58 public void testLoggerSuppressWarnings() throws Exception { 59 RenderLogger l = new RenderLogger("foo"); 60 assertFalse(l.hasProblems()); 61 RenderLogger.ignoreFidelityWarning("No perspective Transforms"); 62 l.fidelityWarning(null, "No perspective Transforms", null, null); 63 l.fidelityWarning(null, "No GPS", null, null); 64 assertTrue(l.hasProblems()); 65 assertEquals("The graphics preview in the layout editor may not be accurate:\n" 66 + "* No GPS\n", l.getProblems(true)); 67 assertEquals("", l.getProblems(false)); 68 assertFalse(l.seenTag("foo")); 69 assertFalse(l.seenTag(null)); 70 71 l = new RenderLogger("foo"); 72 assertFalse(l.hasProblems()); 73 RenderLogger.ignoreFidelityWarning("No perspective Transforms"); 74 RenderLogger.ignoreFidelityWarning("No GPS"); 75 l.fidelityWarning(null, "No perspective Transforms", null, null); 76 l.fidelityWarning(null, "No GPS", null, null); 77 assertFalse(l.hasProblems()); 78 assertEquals("", l.getProblems(true)); 79 assertFalse(l.seenTag("foo")); 80 assertFalse(l.seenTag(null)); 81 } 82 } 83