|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 package org.mozilla.gecko.background.sync.helpers; |
|
5 |
|
6 import static junit.framework.Assert.assertEquals; |
|
7 import static junit.framework.Assert.assertFalse; |
|
8 |
|
9 import java.util.Arrays; |
|
10 import java.util.HashSet; |
|
11 import java.util.Set; |
|
12 |
|
13 import junit.framework.AssertionFailedError; |
|
14 |
|
15 public class ExpectGuidsSinceDelegate extends DefaultGuidsSinceDelegate { |
|
16 private String[] expected; |
|
17 public Set<String> ignore = new HashSet<String>(); |
|
18 |
|
19 public ExpectGuidsSinceDelegate(String[] guids) { |
|
20 expected = guids; |
|
21 Arrays.sort(expected); |
|
22 } |
|
23 |
|
24 @Override |
|
25 public void onGuidsSinceSucceeded(String[] guids) { |
|
26 AssertionFailedError err = null; |
|
27 try { |
|
28 int notIgnored = 0; |
|
29 for (String guid : guids) { |
|
30 if (!ignore.contains(guid)) { |
|
31 notIgnored++; |
|
32 assertFalse(-1 == Arrays.binarySearch(this.expected, guid)); |
|
33 } |
|
34 } |
|
35 assertEquals(this.expected.length, notIgnored); |
|
36 } catch (AssertionFailedError e) { |
|
37 err = e; |
|
38 } |
|
39 performNotify(err); |
|
40 } |
|
41 } |