EMMA Coverage Report (generated Tue Aug 20 10:07:21 PDT 2013)
[all classes][org.chromium.chrome.testshell]

COVERAGE SUMMARY FOR SOURCE FILE [TabManager.java]

nameclass, %method, %block, %line, %
TabManager.java100% (2/2)100% (12/12)92%  (131/142)92%  (28.6/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TabManager100% (1/1)100% (10/10)91%  (113/124)92%  (26.6/29)
setCurrentTab (TestShellTab): void 100% (1/1)76%  (29/38)78%  (7/9)
isContentViewRenderViewInitialized (): boolean 100% (1/1)91%  (10/11)90%  (0.9/1)
createTab (String): void 100% (1/1)94%  (16/17)94%  (3.8/4)
TabManager (Context, AttributeSet): void 100% (1/1)100% (8/8)100% (3/3)
access$000 (TabManager): TestShellTab 100% (1/1)100% (3/3)100% (1/1)
access$100 (TabManager): String 100% (1/1)100% (3/3)100% (1/1)
getCurrentTab (): TestShellTab 100% (1/1)100% (3/3)100% (1/1)
onFinishInflate (): void 100% (1/1)100% (33/33)100% (6/6)
setStartupUrl (String): void 100% (1/1)100% (4/4)100% (2/2)
setWindow (WindowAndroid): void 100% (1/1)100% (4/4)100% (2/2)
     
class TabManager$1100% (1/1)100% (2/2)100% (18/18)100% (3/3)
TabManager$1 (TabManager, Context): void 100% (1/1)100% (7/7)100% (1/1)
onReadyToRender (): void 100% (1/1)100% (11/11)100% (2/2)

1// Copyright (c) 2012 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;
6 
7import android.content.Context;
8import android.util.AttributeSet;
9import android.view.View;
10import android.view.ViewGroup;
11import android.widget.FrameLayout;
12import android.widget.LinearLayout;
13 
14import org.chromium.content.browser.ContentViewRenderView;
15import org.chromium.ui.WindowAndroid;
16 
17/**
18 * The TabManager hooks together all of the related {@link View}s that are used to represent
19 * a {@link TestShellTab}.  It properly builds a {@link TestShellTab} and makes sure that the
20 * {@link Toolbar} and {@link ContentViewRenderView} show the proper content.
21 */
22public class TabManager extends LinearLayout {
23    private static final String DEFAULT_URL = "http://www.google.com";
24 
25    private WindowAndroid mWindow;
26    private ViewGroup mContentViewHolder;
27    private ContentViewRenderView mContentViewRenderView;
28    private TestShellToolbar mToolbar;
29 
30    private TestShellTab mCurrentTab;
31 
32    private String mStartupUrl = DEFAULT_URL;
33 
34    /**
35     * @param context The Context the view is running in.
36     * @param attrs   The attributes of the XML tag that is inflating the view.
37     */
38    public TabManager(Context context, AttributeSet attrs) {
39        super(context, attrs);
40    }
41 
42    @Override
43    protected void onFinishInflate() {
44        super.onFinishInflate();
45 
46        mContentViewHolder = (ViewGroup) findViewById(R.id.content_container);
47        mToolbar = (TestShellToolbar) findViewById(R.id.toolbar);
48        mContentViewRenderView = new ContentViewRenderView(getContext()) {
49            @Override
50            protected void onReadyToRender() {
51                if (mCurrentTab == null) createTab(mStartupUrl);
52            }
53        };
54        mContentViewHolder.addView(mContentViewRenderView,
55                new FrameLayout.LayoutParams(
56                        FrameLayout.LayoutParams.MATCH_PARENT,
57                        FrameLayout.LayoutParams.MATCH_PARENT));
58    }
59 
60    /**
61     * @param window The window used to generate all ContentViews.
62     */
63    public void setWindow(WindowAndroid window) {
64        mWindow = window;
65    }
66 
67    /**
68     * @param startupUrl The URL that the first tab should navigate to.
69     */
70    public void setStartupUrl(String startupUrl) {
71        mStartupUrl = startupUrl;
72    }
73 
74    /**
75     * @return The currently visible {@link TestShellTab}.
76     */
77    public TestShellTab getCurrentTab() {
78        return mCurrentTab;
79    }
80 
81    /**
82     * Creates a {@link TestShellTab} with a URL specified by {@code url}.
83     * @param url The URL the new {@link TestShellTab} should start with.
84     */
85    public void createTab(String url) {
86        if (!isContentViewRenderViewInitialized()) return;
87 
88        TestShellTab tab = new TestShellTab(getContext(), url, mWindow);
89        setCurrentTab(tab);
90    }
91 
92    private boolean isContentViewRenderViewInitialized() {
93        return mContentViewRenderView != null && mContentViewRenderView.isInitialized();
94    }
95 
96    private void setCurrentTab(TestShellTab tab) {
97        if (mCurrentTab != null) {
98            mContentViewHolder.removeView(mCurrentTab.getContentView());
99            mCurrentTab.destroy();
100        }
101 
102        mCurrentTab = tab;
103 
104        mToolbar.showTab(mCurrentTab);
105        mContentViewHolder.addView(mCurrentTab.getContentView());
106        mContentViewRenderView.setCurrentContentView(mCurrentTab.getContentView());
107        mCurrentTab.getContentView().requestFocus();
108    }
109}

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