EMMA Coverage Report (generated Fri Aug 23 16:39:17 PDT 2013)
[all classes][org.chromium.base]

COVERAGE SUMMARY FOR SOURCE FILE [ContextTypesTest.java]

nameclass, %method, %block, %line, %
ContextTypesTest.java100% (1/1)100% (4/4)84%  (46/55)83%  (15/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ContextTypesTest100% (1/1)100% (4/4)84%  (46/55)83%  (15/18)
testPutInvalidTypeThrowsException (): void 100% (1/1)40%  (6/15)57%  (4/7)
ContextTypesTest (): void 100% (1/1)100% (3/3)100% (1/1)
testAbsentContextReturnsNormalType (): void 100% (1/1)100% (8/8)100% (2/2)
testReturnsExpectedType (): void 100% (1/1)100% (29/29)100% (8/8)

1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4 
5package org.chromium.base;
6 
7import android.content.Context;
8import android.test.AndroidTestCase;
9import android.test.mock.MockContext;
10import android.test.suitebuilder.annotation.SmallTest;
11 
12import static org.chromium.base.ContextTypes.CONTEXT_TYPE_NORMAL;
13import static org.chromium.base.ContextTypes.CONTEXT_TYPE_WEBAPP;
14 
15public class ContextTypesTest extends AndroidTestCase {
16 
17    @SmallTest
18    public void testReturnsExpectedType() {
19        ContextTypes contextTypes = ContextTypes.getInstance();
20        Context normal = new MockContext();
21        Context webapp = new MockContext();
22        contextTypes.put(normal, CONTEXT_TYPE_NORMAL);
23        contextTypes.put(webapp, CONTEXT_TYPE_WEBAPP);
24        assertEquals(CONTEXT_TYPE_NORMAL, contextTypes.getType(normal));
25        assertEquals(CONTEXT_TYPE_WEBAPP, contextTypes.getType(webapp));
26    }
27 
28    @SmallTest
29    public void testAbsentContextReturnsNormalType() {
30        assertEquals(CONTEXT_TYPE_NORMAL, ContextTypes.getInstance().getType(new MockContext()));
31    }
32 
33    @SmallTest
34    public void testPutInvalidTypeThrowsException() {
35        boolean exceptionThrown = false;
36        try {
37            ContextTypes.getInstance().put(new MockContext(), -1);
38        } catch (IllegalArgumentException e) {
39            exceptionThrown = true;
40        }
41        assertTrue(exceptionThrown);
42    }
43}

[all classes][org.chromium.base]
EMMA 2.0.5312 (C) Vladimir Roubtsov