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

COVERAGE SUMMARY FOR SOURCE FILE [ViewAndroid.java]

nameclass, %method, %block, %line, %
ViewAndroid.java100% (1/1)71%  (5/7)46%  (42/91)53%  (12.8/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ViewAndroid100% (1/1)71%  (5/7)46%  (42/91)53%  (12.8/24)
decrementKeepScreenOnCount (): void 0%   (0/1)0%   (0/27)0%   (0/6)
incrementKeepScreenOnCount (): void 0%   (0/1)0%   (0/20)0%   (0/5)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
ViewAndroid (WindowAndroid, ViewAndroidDelegate): void 100% (1/1)100% (19/19)100% (6/6)
destroy (): void 100% (1/1)100% (11/11)100% (4/4)
getNativePointer (): int 100% (1/1)100% (3/3)100% (1/1)
getViewAndroidDelegate (): ViewAndroidDelegate 100% (1/1)100% (3/3)100% (1/1)

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.ui;
6 
7import android.view.View;
8 
9import org.chromium.base.JNINamespace;
10import org.chromium.ui.ViewAndroidDelegate;
11import org.chromium.ui.WindowAndroid;
12 
13/**
14 * From the Chromium architecture point of view, ViewAndroid and its native counterpart
15 * serve purpose of representing Android view where Chrome expects to have a cross platform
16 * handle to the system view type. As Views are Java object on Android, this ViewAndroid
17 * and its native counterpart provide the expected abstractions on the C++ side and allow
18 * it to be flexibly glued to an actual Android Java View at runtime.
19 *
20 * It should only be used where access to Android Views is needed from the C++ code.
21 */
22@JNINamespace("ui")
23public class ViewAndroid {
24    // Native pointer to the c++ ViewAndroid object.
25    private int mNativeViewAndroid = 0;
26    private final ViewAndroidDelegate mViewAndroidDelegate;
27    private final WindowAndroid mWindowAndroid;
28    private int mKeepScreenOnCount;
29    private View mKeepScreenOnView;
30 
31    /**
32     * Constructs a View object.
33     */
34    public ViewAndroid(WindowAndroid nativeWindow, ViewAndroidDelegate viewAndroidDelegate) {
35        mWindowAndroid = nativeWindow;
36        mViewAndroidDelegate = viewAndroidDelegate;
37        mNativeViewAndroid = nativeInit(mWindowAndroid.getNativePointer());
38    }
39 
40    public ViewAndroidDelegate getViewAndroidDelegate() {
41        return mViewAndroidDelegate;
42    }
43 
44    /**
45     * Destroys the c++ ViewAndroid object if one has been created.
46     */
47    public void destroy() {
48        if (mNativeViewAndroid != 0) {
49            nativeDestroy(mNativeViewAndroid);
50            mNativeViewAndroid = 0;
51        }
52    }
53 
54    /**
55     * Returns a pointer to the c++ AndroidWindow object.
56     * @return A pointer to the c++ AndroidWindow.
57     */
58    public int getNativePointer() {
59        return mNativeViewAndroid;
60    }
61 
62    /**
63     * Set KeepScreenOn flag. If the flag already set, increase mKeepScreenOnCount.
64     */
65    public void incrementKeepScreenOnCount() {
66        mKeepScreenOnCount++;
67        if (mKeepScreenOnCount == 1) {
68            mKeepScreenOnView = mViewAndroidDelegate.acquireAnchorView();
69            mKeepScreenOnView.setKeepScreenOn(true);
70        }
71    }
72 
73    /**
74     * Decrease mKeepScreenOnCount, if it is decreased to 0, remove the flag.
75     */
76    public void decrementKeepScreenOnCount() {
77        assert mKeepScreenOnCount > 0;
78        mKeepScreenOnCount--;
79        if (mKeepScreenOnCount == 0) {
80            mViewAndroidDelegate.releaseAnchorView(mKeepScreenOnView);
81            mKeepScreenOnView = null;
82        }
83    }
84 
85    private native int nativeInit(int windowPtr);
86    private native void nativeDestroy(int nativeViewAndroid);
87}

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