2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.tools.layoutlib.create;
19 import static org.junit.Assert.*;
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
25 public class LogTest {
30 public void setUp() throws Exception {
35 public void tearDown() throws Exception {
40 public void testDebug() {
41 assertEquals("", mLog.getOut());
42 assertEquals("", mLog.getErr());
44 mLog.setVerbose(false);
45 mLog.debug("Test %d", 42);
46 assertEquals("", mLog.getOut());
48 mLog.setVerbose(true);
49 mLog.debug("Test %d", 42);
51 assertEquals("Test 42\n", mLog.getOut());
52 assertEquals("", mLog.getErr());
56 public void testInfo() {
57 assertEquals("", mLog.getOut());
58 assertEquals("", mLog.getErr());
60 mLog.info("Test %d", 43);
62 assertEquals("Test 43\n", mLog.getOut());
63 assertEquals("", mLog.getErr());
67 public void testError() {
68 assertEquals("", mLog.getOut());
69 assertEquals("", mLog.getErr());
71 mLog.error("Test %d", 44);
73 assertEquals("", mLog.getOut());
74 assertEquals("Test 44\n", mLog.getErr());
78 public void testException() {
79 assertEquals("", mLog.getOut());
80 assertEquals("", mLog.getErr());
82 Exception e = new Exception("My Exception");
83 mLog.exception(e, "Test %d", 44);
85 assertEquals("", mLog.getOut());
86 assertTrue(mLog.getErr().startsWith("Test 44\njava.lang.Exception: My Exception"));