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

COVERAGE SUMMARY FOR SOURCE FILE [AwShellActivity.java]

nameclass, %method, %block, %line, %
AwShellActivity.java0%   (0/6)0%   (0/22)0%   (0/337)0%   (0/61)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AwShellActivity0%   (0/1)0%   (0/12)0%   (0/197)0%   (0/39)
AwShellActivity (): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$000 (AwShellActivity): EditText 0%   (0/1)0%   (0/3)0%   (0/1)
access$100 (AwShellActivity): AwTestContainerView 0%   (0/1)0%   (0/3)0%   (0/1)
access$200 (AwShellActivity, boolean): void 0%   (0/1)0%   (0/4)0%   (0/1)
access$300 (AwShellActivity): ImageButton 0%   (0/1)0%   (0/3)0%   (0/1)
access$400 (AwShellActivity): ImageButton 0%   (0/1)0%   (0/3)0%   (0/1)
createAwTestContainerView (): AwTestContainerView 0%   (0/1)0%   (0/43)0%   (0/8)
getUrlFromIntent (Intent): String 0%   (0/1)0%   (0/7)0%   (0/1)
initializeNavigationButtons (): void 0%   (0/1)0%   (0/27)0%   (0/5)
initializeUrlField (): void 0%   (0/1)0%   (0/21)0%   (0/4)
onCreate (Bundle): void 0%   (0/1)0%   (0/58)0%   (0/15)
setKeyboardVisibilityForUrl (boolean): void 0%   (0/1)0%   (0/22)0%   (0/5)
     
class AwShellActivity$10%   (0/1)0%   (0/2)0%   (0/16)0%   (0/4)
AwShellActivity$1 (AwShellActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
onPageStarted (String): void 0%   (0/1)0%   (0/10)0%   (0/3)
     
class AwShellActivity$20%   (0/1)0%   (0/2)0%   (0/48)0%   (0/8)
AwShellActivity$2 (AwShellActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
onEditorAction (TextView, int, KeyEvent): boolean 0%   (0/1)0%   (0/42)0%   (0/7)
     
class AwShellActivity$30%   (0/1)0%   (0/2)0%   (0/40)0%   (0/7)
AwShellActivity$3 (AwShellActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
onFocusChange (View, boolean): void 0%   (0/1)0%   (0/34)0%   (0/6)
     
class AwShellActivity$40%   (0/1)0%   (0/2)0%   (0/18)0%   (0/4)
AwShellActivity$4 (AwShellActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
onClick (View): void 0%   (0/1)0%   (0/12)0%   (0/3)
     
class AwShellActivity$50%   (0/1)0%   (0/2)0%   (0/18)0%   (0/4)
AwShellActivity$5 (AwShellActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
onClick (View): void 0%   (0/1)0%   (0/12)0%   (0/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.android_webview.shell;
6 
7import android.app.Activity;
8import android.content.Intent;
9import android.content.Context;
10import android.content.SharedPreferences;
11import android.os.Bundle;
12import android.text.TextUtils;
13import android.util.Log;
14import android.view.KeyEvent;
15import android.view.View;
16import android.view.View.OnClickListener;
17import android.view.View.OnFocusChangeListener;
18import android.view.ViewGroup.LayoutParams;
19import android.view.WindowManager;
20import android.view.inputmethod.EditorInfo;
21import android.view.inputmethod.InputMethodManager;
22import android.widget.EditText;
23import android.widget.ImageButton;
24import android.widget.LinearLayout;
25import android.widget.TextView;
26import android.widget.TextView.OnEditorActionListener;
27 
28import org.chromium.android_webview.AwBrowserProcess;
29import org.chromium.android_webview.AwBrowserContext;
30import org.chromium.android_webview.AwContents;
31import org.chromium.android_webview.AwContentsClient;
32import org.chromium.android_webview.test.AwTestContainerView;
33import org.chromium.android_webview.test.NullContentsClient;
34import org.chromium.content.browser.LoadUrlParams;
35 
36/*
37 * This is a lightweight activity for tests that only require WebView functionality.
38 */
39public class AwShellActivity extends Activity {
40    private final static String PREFERENCES_NAME = "AwShellPrefs";
41    private final static String INITIAL_URL = "about:blank";
42    private AwBrowserContext mBrowserContext;
43    private AwTestContainerView mAwTestContainerView;
44    private EditText mUrlTextView;
45    private ImageButton mPrevButton;
46    private ImageButton mNextButton;
47 
48    @Override
49    public void onCreate(Bundle savedInstanceState) {
50        super.onCreate(savedInstanceState);
51 
52        setContentView(R.layout.testshell_activity);
53 
54        mAwTestContainerView = createAwTestContainerView();
55 
56        LinearLayout contentContainer = (LinearLayout) findViewById(R.id.content_container);
57        mAwTestContainerView.setLayoutParams(new LinearLayout.LayoutParams(
58                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f));
59        contentContainer.addView(mAwTestContainerView);
60        mAwTestContainerView.requestFocus();
61 
62        initializeUrlField();
63        initializeNavigationButtons();
64 
65        String startupUrl = getUrlFromIntent(getIntent());
66        if (TextUtils.isEmpty(startupUrl)) {
67            startupUrl = INITIAL_URL;
68        }
69 
70        mAwTestContainerView.getAwContents().loadUrl(new LoadUrlParams(startupUrl));
71        mUrlTextView.setText(startupUrl);
72    }
73 
74    private AwTestContainerView createAwTestContainerView() {
75        AwTestContainerView testContainerView = new AwTestContainerView(this);
76        AwContentsClient awContentsClient = new NullContentsClient() {
77            @Override
78            public void onPageStarted(String url) {
79                if (mUrlTextView != null) {
80                    mUrlTextView.setText(url);
81                }
82            }
83        };
84 
85        SharedPreferences sharedPreferences =
86            getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE);
87        if (mBrowserContext == null) {
88            mBrowserContext = new AwBrowserContext(sharedPreferences);
89        }
90        testContainerView.initialize(new AwContents(mBrowserContext, testContainerView,
91                testContainerView.getInternalAccessDelegate(),
92                awContentsClient, false));
93        testContainerView.getAwContents().getSettings().setJavaScriptEnabled(true);
94        return testContainerView;
95    }
96 
97    private static String getUrlFromIntent(Intent intent) {
98        return intent != null ? intent.getDataString() : null;
99    }
100 
101    private void setKeyboardVisibilityForUrl(boolean visible) {
102        InputMethodManager imm = (InputMethodManager) getSystemService(
103                Context.INPUT_METHOD_SERVICE);
104        if (visible) {
105            imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
106        } else {
107            imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
108        }
109    }
110 
111    private void initializeUrlField() {
112        mUrlTextView = (EditText) findViewById(R.id.url);
113        mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
114            @Override
115            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
116                if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null ||
117                        event.getKeyCode() != KeyEvent.KEYCODE_ENTER ||
118                        event.getKeyCode() != KeyEvent.ACTION_DOWN)) {
119                    return false;
120                }
121 
122                mAwTestContainerView.getAwContents().loadUrl(
123                        new LoadUrlParams(mUrlTextView.getText().toString()));
124                mUrlTextView.clearFocus();
125                setKeyboardVisibilityForUrl(false);
126                mAwTestContainerView.requestFocus();
127                return true;
128            }
129        });
130        mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
131            @Override
132            public void onFocusChange(View v, boolean hasFocus) {
133                setKeyboardVisibilityForUrl(hasFocus);
134                mNextButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
135                mPrevButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
136                if (!hasFocus) {
137                    mUrlTextView.setText(mAwTestContainerView.getContentViewCore().getUrl());
138                }
139            }
140        });
141    }
142 
143    private void initializeNavigationButtons() {
144        mPrevButton = (ImageButton) findViewById(R.id.prev);
145        mPrevButton.setOnClickListener(new OnClickListener() {
146            @Override
147            public void onClick(View v) {
148                if (mAwTestContainerView.getContentViewCore().canGoBack()) {
149                    mAwTestContainerView.getContentViewCore().goBack();
150                }
151            }
152        });
153 
154        mNextButton = (ImageButton) findViewById(R.id.next);
155        mNextButton.setOnClickListener(new OnClickListener() {
156            @Override
157            public void onClick(View v) {
158                if (mAwTestContainerView.getContentViewCore().canGoForward()) {
159                        mAwTestContainerView.getContentViewCore().goForward();
160                }
161            }
162        });
163    }
164}

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