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

COVERAGE SUMMARY FOR SOURCE FILE [TestableInvalidationService.java]

nameclass, %method, %block, %line, %
TestableInvalidationService.java100% (1/1)100% (9/9)100% (95/95)100% (27/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestableInvalidationService100% (1/1)100% (9/9)100% (95/95)100% (27/27)
TestableInvalidationService (): void 100% (1/1)100% (34/34)100% (9/9)
acknowledge (byte []): void 100% (1/1)100% (6/6)100% (2/2)
isChromeInForeground (): boolean 100% (1/1)100% (3/3)100% (1/1)
isSyncEnabled (): boolean 100% (1/1)100% (3/3)100% (1/1)
register (byte [], Iterable): void 100% (1/1)100% (11/11)100% (3/3)
requestSyncFromContentResolver (Bundle, Account, String): void 100% (1/1)100% (11/11)100% (3/3)
setShouldRunStates (boolean, boolean): void 100% (1/1)100% (7/7)100% (3/3)
startService (Intent): ComponentName 100% (1/1)100% (9/9)100% (2/2)
unregister (byte [], Iterable): void 100% (1/1)100% (11/11)100% (3/3)

1// Copyright (c) 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.sync.notifier;
6 
7import android.accounts.Account;
8import android.content.ComponentName;
9import android.content.Intent;
10import android.os.Bundle;
11 
12import com.google.ipc.invalidation.external.client.types.ObjectId;
13 
14import org.chromium.base.CollectionUtil;
15 
16import java.util.ArrayList;
17import java.util.List;
18 
19/**
20 * Subclass of {@link InvalidationService} that captures events and allows controlling
21 * whether or not Chrome is in the foreground and sync is enabled.
22 *
23 * @author dsmyers@google.com (Daniel Myers)
24 */
25public class TestableInvalidationService extends InvalidationService {
26    /** Object ids given to {@link #register}, one list element per call. */
27    final List<List<ObjectId>> mRegistrations = new ArrayList<List<ObjectId>>();
28 
29    /** Object ids given to {@link #unregister}, one list element per call. */
30    final List<List<ObjectId>> mUnregistrations = new ArrayList<List<ObjectId>>();
31 
32    /** Intents given to {@link #startService}. */
33    final List<Intent> mStartedServices = new ArrayList<Intent>();
34 
35    /** Bundles given to {@link #requestSyncFromContentResolver}. */
36    final List<Bundle> mRequestedSyncs = new ArrayList<Bundle>();
37 
38    final List<byte[]> mAcknowledgements = new ArrayList<byte[]>();
39 
40    /** Whether Chrome is in the foreground. */
41    private boolean mIsChromeInForeground = false;
42 
43    /** Whether sync is enabled. */
44    private boolean mIsSyncEnabled = false;
45 
46    public TestableInvalidationService() {
47    }
48 
49    @Override
50    public void acknowledge(byte[] ackHandle) {
51        mAcknowledgements.add(ackHandle);
52    }
53 
54    @Override
55    public void register(byte[] clientId, Iterable<ObjectId> objectIds) {
56        mRegistrations.add(CollectionUtil.newArrayList(objectIds));
57        super.register(clientId, objectIds);
58    }
59 
60    @Override
61    public void unregister(byte[] clientId, Iterable<ObjectId> objectIds) {
62        mUnregistrations.add(CollectionUtil.newArrayList(objectIds));
63        super.unregister(clientId, objectIds);
64    }
65 
66    @Override
67    public ComponentName startService(Intent intent) {
68        mStartedServices.add(intent);
69        return super.startService(intent);
70    }
71 
72    @Override
73    public void requestSyncFromContentResolver(Bundle bundle, Account account,
74            String contractAuthority) {
75        mRequestedSyncs.add(bundle);
76        super.requestSyncFromContentResolver(bundle, account, contractAuthority);
77    }
78 
79    @Override
80    boolean isChromeInForeground() {
81        return mIsChromeInForeground;
82    }
83 
84    @Override
85    boolean isSyncEnabled() {
86        return mIsSyncEnabled;
87    }
88 
89    /**
90     * Sets the variables used to control whether or not a notification client should be running.
91     * @param isChromeInForeground whether Chrome is in the foreground
92     * @param isSyncEnabled whether sync is enabled
93     */
94    void setShouldRunStates(boolean isChromeInForeground, boolean isSyncEnabled) {
95        this.mIsChromeInForeground = isChromeInForeground;
96        this.mIsSyncEnabled = isSyncEnabled;
97    }
98}

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