• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 
17 package com.android.exchange;
18 
19 import android.content.Context;
20 import android.test.AndroidTestCase;
21 import android.test.suitebuilder.annotation.SmallTest;
22 
23 /**
24  * You can run this entire test case with:
25  *   runtest -c com.android.exchange.EasAccountServiceTests exchange
26  */
27 @SmallTest
28 public class EasAccountServiceTests extends AndroidTestCase {
29 
30     Context mMockContext;
31 
32     @Override
setUp()33     public void setUp() throws Exception {
34         super.setUp();
35         mMockContext = getContext();
36     }
37 
testResetHeartbeats()38     public void testResetHeartbeats() {
39         EasAccountService svc = new EasAccountService();
40         // Test case in which the minimum and force heartbeats need to come up
41         svc.mPingMaxHeartbeat = 1000;
42         svc.mPingMinHeartbeat = 200;
43         svc.mPingHeartbeat = 300;
44         svc.mPingForceHeartbeat = 100;
45         svc.mPingHeartbeatDropped = true;
46         svc.resetHeartbeats(400);
47         assertEquals(400, svc.mPingMinHeartbeat);
48         assertEquals(1000, svc.mPingMaxHeartbeat);
49         assertEquals(400, svc.mPingHeartbeat);
50         assertEquals(400, svc.mPingForceHeartbeat);
51         assertFalse(svc.mPingHeartbeatDropped);
52 
53         // Test case in which the force heartbeat needs to come up
54         svc.mPingMaxHeartbeat = 1000;
55         svc.mPingMinHeartbeat = 200;
56         svc.mPingHeartbeat = 100;
57         svc.mPingForceHeartbeat = 100;
58         svc.mPingHeartbeatDropped = true;
59         svc.resetHeartbeats(150);
60         assertEquals(200, svc.mPingMinHeartbeat);
61         assertEquals(1000, svc.mPingMaxHeartbeat);
62         assertEquals(150, svc.mPingHeartbeat);
63         assertEquals(150, svc.mPingForceHeartbeat);
64         assertFalse(svc.mPingHeartbeatDropped);
65 
66         // Test case in which the maximum needs to come down
67         svc.mPingMaxHeartbeat = 1000;
68         svc.mPingMinHeartbeat = 200;
69         svc.mPingHeartbeat = 800;
70         svc.mPingForceHeartbeat = 100;
71         svc.mPingHeartbeatDropped = true;
72         svc.resetHeartbeats(600);
73         assertEquals(200, svc.mPingMinHeartbeat);
74         assertEquals(600, svc.mPingMaxHeartbeat);
75         assertEquals(600, svc.mPingHeartbeat);
76         assertEquals(100, svc.mPingForceHeartbeat);
77         assertFalse(svc.mPingHeartbeatDropped);
78     }
79 }
80