1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.wallpaper.testing;
17 
18 import android.app.PendingIntent;
19 
20 import com.android.wallpaper.module.AlarmManagerWrapper;
21 
22 /**
23  * Mock of {@link AlarmManagerWrapper}.
24  */
25 public class TestAlarmManagerWrapper implements AlarmManagerWrapper {
26 
27     private int mExactAlarmSetCount;
28     private int mInexactAlarmSetCount;
29     private int mAlarmCanceledCount;
30 
31     private long mLastInexactTriggerAtMillis;
32 
33     @Override
set(int type, long triggerAtMillis, PendingIntent operation)34     public void set(int type, long triggerAtMillis, PendingIntent operation) {
35         mExactAlarmSetCount++;
36     }
37 
38     @Override
setWindow(int type, long windowStartMillis, long windowLengthMillis, PendingIntent operation)39     public void setWindow(int type, long windowStartMillis, long windowLengthMillis,
40             PendingIntent operation) {
41         mExactAlarmSetCount++;
42     }
43 
44     @Override
setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation)45     public void setInexactRepeating(int type, long triggerAtMillis, long intervalMillis,
46             PendingIntent operation) {
47         mInexactAlarmSetCount++;
48         mLastInexactTriggerAtMillis = triggerAtMillis;
49     }
50 
51     @Override
cancel(PendingIntent operation)52     public void cancel(PendingIntent operation) {
53         mAlarmCanceledCount++;
54     }
55 
getExactAlarmSetCount()56     public int getExactAlarmSetCount() {
57         return mExactAlarmSetCount;
58     }
59 
getInexactAlarmSetCount()60     public int getInexactAlarmSetCount() {
61         return mInexactAlarmSetCount;
62     }
63 
getAlarmCanceledCount()64     public int getAlarmCanceledCount() {
65         return mAlarmCanceledCount;
66     }
67 
getLastInexactTriggerAtMillis()68     public long getLastInexactTriggerAtMillis() {
69         return mLastInexactTriggerAtMillis;
70     }
71 }
72