1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
1
4
package org .mozilla .mozstumbler .client ;
2
5
3
6
import org .junit .Before ;
4
7
import org .junit .Test ;
5
8
import org .junit .runner .RunWith ;
6
-
9
+ import org . mozilla . mozstumbler . client . navdrawer . MainDrawerActivity ;
7
10
import org .mozilla .mozstumbler .service .core .http .IHttpUtil ;
8
11
import org .mozilla .mozstumbler .service .core .http .MockHttpUtil ;
9
- import org .mozilla .mozstumbler .client .navdrawer .MainDrawerActivity ;
10
-
11
12
import org .robolectric .Robolectric ;
12
13
import org .robolectric .RobolectricTestRunner ;
13
14
import org .robolectric .annotation .Config ;
14
15
16
+ import static junit .framework .Assert .assertEquals ;
15
17
import static org .junit .Assert .assertFalse ;
16
18
import static org .junit .Assert .assertNotNull ;
17
19
import static org .junit .Assert .assertTrue ;
18
20
21
+
19
22
@ Config (emulateSdk = 18 )
20
23
@ RunWith (RobolectricTestRunner .class )
21
- public class MainDrawerActivityTest {
24
+ public class UpdaterTest {
25
+ class TestUpdater extends Updater {
26
+ public TestUpdater (IHttpUtil simpleHttp ) {
27
+ super (simpleHttp );
28
+ }
29
+
30
+ @ Override
31
+ public boolean wifiExclusiveAndUnavailable () {
32
+ return false ;
33
+ }
34
+ }
22
35
23
36
private MainDrawerActivity activity ;
24
37
@@ -32,28 +45,23 @@ public void activityShouldNotBeNull() {
32
45
assertNotNull (activity );
33
46
}
34
47
35
-
36
48
@ Test
37
49
public void testUpdater () {
38
-
39
- class TestUpdater extends Updater {
40
- public TestUpdater (IHttpUtil simpleHttp ) {
41
- super (simpleHttp );
42
- }
43
-
44
- @ Override
45
- public boolean wifiExclusiveAndUnavailable () {
46
- return false ;
47
- }
48
- }
49
-
50
50
IHttpUtil mockHttp = new MockHttpUtil ();
51
-
52
-
53
51
Updater upd = new TestUpdater (mockHttp );
54
52
assertFalse (upd .checkForUpdates (activity , "" ));
55
53
assertFalse (upd .checkForUpdates (activity , null ));
56
54
assertTrue (upd .checkForUpdates (activity , "anything_else" ));
55
+
56
+ assertEquals ("1.3.0" , upd .stripBuildHostName ("1.3.0.Victors-MBPr" ));
57
+ assertEquals ("1.3.0" , upd .stripBuildHostName ("1.3.0" ));
58
+
59
+ }
60
+
61
+ @ Test (expected =RuntimeException .class )
62
+ public void testUpdaterThrowsExceptions () {
63
+ Updater upd = new TestUpdater (null );
64
+ upd .stripBuildHostName ("1.0" );
57
65
}
58
66
59
67
}
0 commit comments