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

COVERAGE SUMMARY FOR SOURCE FILE [TestShellToolbar.java]

nameclass, %method, %block, %line, %
TestShellToolbar.java100% (8/8)67%  (24/36)61%  (233/384)62%  (41.8/68)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestShellToolbar$2100% (1/1)50%  (1/2)13%  (6/45)12%  (1/8)
onEditorAction (TextView, int, KeyEvent): boolean 0%   (0/1)0%   (0/39)0%   (0/7)
TestShellToolbar$2 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
     
class TestShellToolbar$3100% (1/1)50%  (1/2)15%  (6/40)14%  (1/7)
onFocusChange (View, boolean): void 0%   (0/1)0%   (0/34)0%   (0/6)
TestShellToolbar$3 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
     
class TestShellToolbar$4100% (1/1)50%  (1/2)33%  (6/18)33%  (1/3)
onClick (View): void 0%   (0/1)0%   (0/12)0%   (0/2)
TestShellToolbar$4 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
     
class TestShellToolbar$5100% (1/1)50%  (1/2)33%  (6/18)33%  (1/3)
onClick (View): void 0%   (0/1)0%   (0/12)0%   (0/2)
TestShellToolbar$5 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
     
class TestShellToolbar$6100% (1/1)50%  (1/2)40%  (6/15)33%  (1/3)
onClick (View): void 0%   (0/1)0%   (0/9)0%   (0/2)
TestShellToolbar$6 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
     
class TestShellToolbar100% (1/1)68%  (13/19)78%  (160/204)85%  (34.8/41)
access$200 (TestShellToolbar): EditText 0%   (0/1)0%   (0/3)0%   (0/1)
access$400 (TestShellToolbar, boolean): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$500 (TestShellToolbar): ImageButton 0%   (0/1)0%   (0/3)0%   (0/1)
access$600 (TestShellToolbar): ImageButton 0%   (0/1)0%   (0/3)0%   (0/1)
access$700 (TestShellToolbar): MenuHandler 0%   (0/1)0%   (0/3)0%   (0/1)
setKeyboardVisibilityForUrl (boolean): void 0%   (0/1)0%   (0/23)0%   (0/5)
showTab (TestShellTab): void 100% (1/1)79%  (19/24)87%  (4.4/5)
TestShellToolbar (Context, AttributeSet): void 100% (1/1)100% (18/18)100% (4/4)
access$000 (TestShellToolbar): ClipDrawable 100% (1/1)100% (3/3)100% (1/1)
access$300 (TestShellToolbar): TestShellTab 100% (1/1)100% (3/3)100% (1/1)
access$800 (TestShellToolbar, int): void 100% (1/1)100% (4/4)100% (1/1)
access$900 (TestShellToolbar, String): void 100% (1/1)100% (4/4)100% (1/1)
initializeMenuButton (): void 100% (1/1)100% (12/12)100% (3/3)
initializeNavigationButtons (): void 100% (1/1)100% (27/27)100% (5/5)
initializeUrlField (): void 100% (1/1)100% (21/21)100% (4/4)
onFinishInflate (): void 100% (1/1)100% (16/16)100% (6/6)
onLoadProgressChanged (int): void 100% (1/1)100% (24/24)100% (4/4)
onUpdateUrl (String): void 100% (1/1)100% (5/5)100% (2/2)
setMenuHandler (MenuHandler): void 100% (1/1)100% (4/4)100% (2/2)
     
class TestShellToolbar$TestShellTabObserverImpl100% (1/1)80%  (4/5)97%  (30/31)83%  (5/6)
onCloseTab (TestShellTab): void 0%   (0/1)0%   (0/1)0%   (0/1)
TestShellToolbar$TestShellTabObserverImpl (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
TestShellToolbar$TestShellTabObserverImpl (TestShellToolbar, TestShellToolbar... 100% (1/1)100% (4/4)100% (1/1)
onLoadProgressChanged (TestShellTab, int): void 100% (1/1)100% (10/10)100% (2/2)
onUpdateUrl (TestShellTab, String): void 100% (1/1)100% (10/10)100% (2/2)
     
class TestShellToolbar$1100% (1/1)100% (2/2)100% (13/13)100% (3/3)
TestShellToolbar$1 (TestShellToolbar): void 100% (1/1)100% (6/6)100% (1/1)
run (): void 100% (1/1)100% (7/7)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.graphics.drawable.ClipDrawable;
9import android.text.TextUtils;
10import android.util.AttributeSet;
11import android.view.KeyEvent;
12import android.view.View;
13import android.view.View.OnClickListener;
14import android.view.inputmethod.EditorInfo;
15import android.view.inputmethod.InputMethodManager;
16import android.widget.EditText;
17import android.widget.ImageButton;
18import android.widget.LinearLayout;
19import android.widget.TextView;
20import android.widget.TextView.OnEditorActionListener;
21 
22import org.chromium.content.browser.LoadUrlParams;
23 
24/**
25 * A Toolbar {@link View} that shows the URL and navigation buttons.
26 */
27public class TestShellToolbar extends LinearLayout {
28    private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
29 
30    private Runnable mClearProgressRunnable = new Runnable() {
31        @Override
32        public void run() {
33            mProgressDrawable.setLevel(0);
34        }
35    };
36 
37    private EditText mUrlTextView;
38    private ImageButton mPrevButton;
39    private ImageButton mNextButton;
40 
41    private ClipDrawable mProgressDrawable;
42 
43    private TestShellTab mTab;
44    private TestShellTabObserver mTabObserver = new TestShellTabObserverImpl();
45    private MenuHandler mMenuHandler;
46 
47    /**
48     * @param context The Context the view is running in.
49     * @param attrs   The attributes of the XML tag that is inflating the view.
50     */
51    public TestShellToolbar(Context context, AttributeSet attrs) {
52        super(context, attrs);
53    }
54 
55    /**
56     * The toolbar will visually represent the state of {@code tab}.
57     * @param tab The TabBase that should be represented.
58     */
59    public void showTab(TestShellTab tab) {
60        if (mTab != null) mTab.removeObserver(mTabObserver);
61        mTab = tab;
62        mTab.addObserver(mTabObserver);
63        mUrlTextView.setText(mTab.getContentView().getUrl());
64    }
65 
66    private void onUpdateUrl(String url) {
67        mUrlTextView.setText(url);
68    }
69 
70    private void onLoadProgressChanged(int progress) {
71        removeCallbacks(mClearProgressRunnable);
72        mProgressDrawable.setLevel((int) (100.0 * progress));
73        if (progress == 100) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
74    }
75 
76    @Override
77    protected void onFinishInflate() {
78        super.onFinishInflate();
79 
80        mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();
81        initializeUrlField();
82        initializeNavigationButtons();
83        initializeMenuButton();
84    }
85 
86    public void setMenuHandler(MenuHandler menuHandler) {
87        mMenuHandler = menuHandler;
88    }
89 
90    private void initializeUrlField() {
91        mUrlTextView = (EditText) findViewById(R.id.url);
92        mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
93            @Override
94            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
95                if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null ||
96                        event.getKeyCode() != KeyEvent.KEYCODE_ENTER ||
97                        event.getKeyCode() != KeyEvent.ACTION_DOWN)) {
98                    return false;
99                }
100 
101                mTab.loadUrlWithSanitization(mUrlTextView.getText().toString());
102                mUrlTextView.clearFocus();
103                setKeyboardVisibilityForUrl(false);
104                mTab.getContentView().requestFocus();
105                return true;
106            }
107        });
108        mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
109            @Override
110            public void onFocusChange(View v, boolean hasFocus) {
111                setKeyboardVisibilityForUrl(hasFocus);
112                mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
113                mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
114                if (!hasFocus) {
115                    mUrlTextView.setText(mTab.getContentView().getUrl());
116                }
117            }
118        });
119    }
120 
121    private void initializeNavigationButtons() {
122        mPrevButton = (ImageButton) findViewById(R.id.prev);
123        mPrevButton.setOnClickListener(new OnClickListener() {
124            @Override
125            public void onClick(View arg0) {
126                if (mTab.getContentView().canGoBack()) mTab.getContentView().goBack();
127            }
128        });
129 
130        mNextButton = (ImageButton) findViewById(R.id.next);
131        mNextButton.setOnClickListener(new OnClickListener() {
132            @Override
133            public void onClick(View v) {
134                if (mTab.getContentView().canGoForward()) mTab.getContentView().goForward();
135            }
136        });
137    }
138 
139    private void initializeMenuButton() {
140        ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button);
141        menuButton.setOnClickListener(new OnClickListener() {
142            @Override
143            public void onClick(View v) {
144                if (mMenuHandler != null) mMenuHandler.showPopupMenu();
145            }
146        });
147    }
148 
149    private void setKeyboardVisibilityForUrl(boolean visible) {
150        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
151                Context.INPUT_METHOD_SERVICE);
152        if (visible) {
153            imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
154        } else {
155            imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
156        }
157    }
158 
159    private class TestShellTabObserverImpl implements TestShellTabObserver {
160        @Override
161        public void onLoadProgressChanged(TestShellTab tab, int progress) {
162            if (tab == mTab) TestShellToolbar.this.onLoadProgressChanged(progress);
163        }
164 
165        @Override
166        public void onUpdateUrl(TestShellTab tab, String url) {
167            if (tab == mTab) TestShellToolbar.this.onUpdateUrl(url);
168        }
169 
170        @Override
171        public void onCloseTab(TestShellTab tab) {
172        }
173    }
174}

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