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

COVERAGE SUMMARY FOR SOURCE FILE [MonthPicker.java]

nameclass, %method, %block, %line, %
MonthPicker.java0%   (0/1)0%   (0/10)0%   (0/151)0%   (0/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MonthPicker0%   (0/1)0%   (0/10)0%   (0/151)0%   (0/34)
MonthPicker (Context, long, long): void 0%   (0/1)0%   (0/29)0%   (0/6)
createDateFromValue (long): Calendar 0%   (0/1)0%   (0/25)0%   (0/6)
getMaxPositionInYear (): int 0%   (0/1)0%   (0/14)0%   (0/3)
getMaxYear (): int 0%   (0/1)0%   (0/5)0%   (0/1)
getMinPositionInYear (): int 0%   (0/1)0%   (0/14)0%   (0/3)
getMinYear (): int 0%   (0/1)0%   (0/5)0%   (0/1)
getMonth (): int 0%   (0/1)0%   (0/5)0%   (0/1)
getPositionInYear (): int 0%   (0/1)0%   (0/3)0%   (0/1)
setCurrentDate (int, int): void 0%   (0/1)0%   (0/31)0%   (0/8)
updateSpinners (): void 0%   (0/1)0%   (0/20)0%   (0/4)

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.content.browser.input;
6 
7import android.content.Context;
8 
9import java.text.DateFormatSymbols;
10import java.util.Arrays;
11import java.util.Calendar;
12import java.util.Locale;
13 
14import org.chromium.content.R;
15 
16public class MonthPicker extends TwoFieldDatePicker {
17    private static final int MONTHS_NUMBER = 12;
18 
19    private String[] mShortMonths;
20 
21    public MonthPicker(Context context, long minValue, long maxValue) {
22        super(context, minValue, maxValue);
23 
24        getPositionInYearSpinner().setContentDescription(
25                getResources().getString(R.string.accessibility_date_picker_month));
26 
27        // initialization based on locale
28        mShortMonths =
29                DateFormatSymbols.getInstance(Locale.getDefault()).getShortMonths();
30 
31        // initialize to current date
32        Calendar cal = Calendar.getInstance();
33        init(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), null);
34    }
35 
36    @Override
37    protected Calendar createDateFromValue(long value) {
38        int year = (int)Math.min(value / 12 + 1970, Integer.MAX_VALUE);
39        int month = (int) (value % 12);
40        Calendar cal = Calendar.getInstance();
41        cal.clear();
42        cal.set(year, month, 1);
43        return cal;
44    }
45 
46    @Override
47    protected void setCurrentDate(int year, int month) {
48        Calendar date = Calendar.getInstance();
49        date.set(year, month, 1);
50        if (date.before(getMinDate())) {
51            setCurrentDate(getMinDate());
52        } else if (date.after(getMaxDate())) {
53            setCurrentDate(getMaxDate());
54        } else {
55            setCurrentDate(date);
56        }
57    }
58 
59    @Override
60    protected void updateSpinners() {
61        super.updateSpinners();
62 
63        // make sure the month names are a zero based array
64        // with the months in the month spinner
65        String[] displayedValues = Arrays.copyOfRange(mShortMonths,
66                getPositionInYearSpinner().getMinValue(),
67                getPositionInYearSpinner().getMaxValue() + 1);
68        getPositionInYearSpinner().setDisplayedValues(displayedValues);
69    }
70 
71    /**
72     * @return The selected month.
73     */
74    public int getMonth() {
75        return getCurrentDate().get(Calendar.MONTH);
76    }
77 
78    @Override
79    public int getPositionInYear() {
80        return getMonth();
81    }
82 
83    @Override
84    protected int getMaxYear() {
85        return getMaxDate().get(Calendar.YEAR);
86    }
87 
88    @Override
89    protected int getMinYear() {
90        return getMinDate().get(Calendar.YEAR);
91    }
92 
93 
94    @Override
95    protected int getMaxPositionInYear() {
96        if (getYear() == getMaxDate().get(Calendar.YEAR)) {
97            return getMaxDate().get(Calendar.MONTH);
98        }
99        return MONTHS_NUMBER - 1;
100    }
101 
102    @Override
103    protected int getMinPositionInYear() {
104        if (getYear() == getMinDate().get(Calendar.YEAR)) {
105            return getMinDate().get(Calendar.MONTH);
106        }
107        return 0;
108    }
109}

[all classes][org.chromium.content.browser.input]
EMMA 2.0.5312 (C) Vladimir Roubtsov