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