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

COVERAGE SUMMARY FOR SOURCE FILE [SyncController.java]

nameclass, %method, %block, %line, %
SyncController.java0%   (0/2)0%   (0/9)0%   (0/82)0%   (0/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SyncController0%   (0/1)0%   (0/6)0%   (0/58)0%   (0/19)
SyncController (Context): void 0%   (0/1)0%   (0/6)0%   (0/3)
access$000 (SyncController): Context 0%   (0/1)0%   (0/3)0%   (0/1)
get (Context): SyncController 0%   (0/1)0%   (0/11)0%   (0/4)
openSignOutDialog (FragmentManager): void 0%   (0/1)0%   (0/9)0%   (0/3)
openSigninDialog (FragmentManager): void 0%   (0/1)0%   (0/9)0%   (0/3)
signIn (Activity, String): void 0%   (0/1)0%   (0/20)0%   (0/5)
     
class SyncController$10%   (0/1)0%   (0/3)0%   (0/24)0%   (0/5)
SyncController$1 (SyncController, Account): void 0%   (0/1)0%   (0/9)0%   (0/1)
onSigninCancelled (): void 0%   (0/1)0%   (0/1)0%   (0/1)
onSigninComplete (): void 0%   (0/1)0%   (0/14)0%   (0/3)

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.chrome.testshell.sync;
6 
7import android.accounts.Account;
8import android.app.Activity;
9import android.app.FragmentManager;
10import android.content.Context;
11 
12import org.chromium.base.ThreadUtils;
13import org.chromium.chrome.browser.signin.SigninManager;
14import org.chromium.chrome.browser.sync.ProfileSyncService;
15import org.chromium.sync.notifier.SyncStatusHelper;
16import org.chromium.sync.signin.AccountManagerHelper;
17 
18/**
19 * A helper class for signing in and out of Chromium.
20 */
21public class SyncController {
22 
23    private static SyncController sInstance;
24 
25    private final Context mContext;
26 
27    private SyncController(Context context) {
28        mContext = context;
29    }
30 
31    /**
32     * Retrieve the singleton instance of this class.
33     *
34     * @param context the current context.
35     * @return the singleton instance.
36     */
37    public static SyncController get(Context context) {
38        ThreadUtils.assertOnUiThread();
39        if (sInstance == null) {
40            sInstance = new SyncController(context.getApplicationContext());
41        }
42        return sInstance;
43    }
44 
45    /**
46     * Open a dialog that gives the user the option to sign in from a list of available accounts.
47     *
48     * @param fragmentManager the FragmentManager.
49     */
50    public static void openSigninDialog(FragmentManager fragmentManager) {
51        AccountChooserFragment chooserFragment = new AccountChooserFragment();
52        chooserFragment.show(fragmentManager, null);
53    }
54 
55    /**
56     * Open a dialog that gives the user the option to sign out.
57     *
58     * @param fragmentManager the FragmentManager.
59     */
60    public static void openSignOutDialog(FragmentManager fragmentManager) {
61        SignoutFragment signoutFragment = new SignoutFragment();
62        signoutFragment.show(fragmentManager, null);
63    }
64 
65    /**
66     * Trigger Chromium sign in of the given account.
67     *
68     * This also ensure that sync setup is not in progress anymore, so sync will start after
69     * sync initialization has happened.
70     *
71     * @param activity the current activity.
72     * @param accountName the full account name.
73     */
74    public void signIn(Activity activity, String accountName) {
75        final Account account = AccountManagerHelper.createAccountFromName(accountName);
76 
77        // The SigninManager handles most of the sign-in flow, and doFinishSignIn handles the
78        // Chromium testshell specific details.
79        SigninManager signinManager = SigninManager.get(mContext);
80        final boolean passive = false;
81        signinManager.startSignIn(activity, account, passive, new SigninManager.Observer() {
82            @Override
83            public void onSigninComplete() {
84                ProfileSyncService.get(mContext).setSetupInProgress(false);
85                // The SigninManager does not control the Android sync state.
86                SyncStatusHelper.get(mContext).enableAndroidSync(account);
87            }
88 
89            @Override
90            public void onSigninCancelled() {
91            }
92        });
93    }
94}

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