| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.sync.notifier; | 5 package org.chromium.sync.notifier; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.content.ComponentName; | 8 import android.content.ComponentName; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.os.Bundle; | 10 import android.os.Bundle; |
| 11 import android.test.ServiceTestCase; | 11 import android.test.ServiceTestCase; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 330 } |
| 331 | 331 |
| 332 @SmallTest | 332 @SmallTest |
| 333 @Feature({"Sync"}) | 333 @Feature({"Sync"}) |
| 334 public void testReadWriteState() { | 334 public void testReadWriteState() { |
| 335 /* | 335 /* |
| 336 * Test plan: read, write, and read the internal notification client per
sistent state. | 336 * Test plan: read, write, and read the internal notification client per
sistent state. |
| 337 * Verify appropriate return values. | 337 * Verify appropriate return values. |
| 338 */ | 338 */ |
| 339 assertNull(getService().readState()); | 339 assertNull(getService().readState()); |
| 340 byte[] writtenState = new byte[]{7,4,0}; | 340 byte[] writtenState = new byte[]{7, 4, 0}; |
| 341 getService().writeState(writtenState); | 341 getService().writeState(writtenState); |
| 342 assertTrue(Arrays.equals(writtenState, getService().readState())); | 342 assertTrue(Arrays.equals(writtenState, getService().readState())); |
| 343 } | 343 } |
| 344 | 344 |
| 345 @SmallTest | 345 @SmallTest |
| 346 @Feature({"Sync"}) | 346 @Feature({"Sync"}) |
| 347 public void testInvalidateWithPayload() { | 347 public void testInvalidateWithPayload() { |
| 348 doTestInvalidate(true); | 348 doTestInvalidate(true); |
| 349 } | 349 } |
| 350 | 350 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 * InvalidationService is correctly configured in the manifest and retri
es registrations | 805 * InvalidationService is correctly configured in the manifest and retri
es registrations |
| 806 * with exponential backoff. May need to be implemented as a downstream
Chrome for Android | 806 * with exponential backoff. May need to be implemented as a downstream
Chrome for Android |
| 807 * test. | 807 * test. |
| 808 */ | 808 */ |
| 809 // TODO(dsmyers): implement. | 809 // TODO(dsmyers): implement. |
| 810 // Bug: https://code.google.com/p/chromium/issues/detail?id=172398 | 810 // Bug: https://code.google.com/p/chromium/issues/detail?id=172398 |
| 811 } | 811 } |
| 812 | 812 |
| 813 /** Creates an intent to start the InvalidationService. */ | 813 /** Creates an intent to start the InvalidationService. */ |
| 814 private Intent createStartIntent() { | 814 private Intent createStartIntent() { |
| 815 Intent intent = new Intent(); | 815 Intent intent = new Intent(); |
| 816 return intent; | 816 return intent; |
| 817 } | 817 } |
| 818 | 818 |
| 819 /** Creates an intent to stop the InvalidationService. */ | 819 /** Creates an intent to stop the InvalidationService. */ |
| 820 private Intent createStopIntent() { | 820 private Intent createStopIntent() { |
| 821 Intent intent = new Intent(); | 821 Intent intent = new Intent(); |
| 822 intent.putExtra(InvalidationIntentProtocol.EXTRA_STOP, true); | 822 intent.putExtra(InvalidationIntentProtocol.EXTRA_STOP, true); |
| 823 return intent; | 823 return intent; |
| 824 } | 824 } |
| 825 | 825 |
| 826 /** Creates an intent to register some types with the InvalidationService. *
/ | 826 /** Creates an intent to register some types with the InvalidationService. *
/ |
| 827 private Intent createRegisterIntent(Account account, boolean allTypes, Set<M
odelType> types) { | 827 private Intent createRegisterIntent(Account account, boolean allTypes, Set<M
odelType> types) { |
| 828 Intent intent = InvalidationIntentProtocol.createRegisterIntent(account, a
llTypes, types); | 828 Intent intent = InvalidationIntentProtocol.createRegisterIntent(account,
allTypes, types); |
| 829 return intent; | 829 return intent; |
| 830 } | 830 } |
| 831 | 831 |
| 832 /** Creates an intent to register some types with the InvalidationService. *
/ | 832 /** Creates an intent to register some types with the InvalidationService. *
/ |
| 833 private Intent createRegisterIntent( | 833 private Intent createRegisterIntent( |
| 834 Account account, int[] objectSources, String[] objectNames) { | 834 Account account, int[] objectSources, String[] objectNames) { |
| 835 Intent intent = InvalidationIntentProtocol.createRegisterIntent( | 835 Intent intent = InvalidationIntentProtocol.createRegisterIntent( |
| 836 account, objectSources, objectNames); | 836 account, objectSources, objectNames); |
| 837 return intent; | 837 return intent; |
| 838 } | 838 } |
| 839 | 839 |
| 840 /** Returns whether {@code intent} is an {@link AndroidListener} start inten
t. */ | 840 /** Returns whether {@code intent} is an {@link AndroidListener} start inten
t. */ |
| 841 private boolean isAndroidListenerStartIntent(Intent intent) { | 841 private boolean isAndroidListenerStartIntent(Intent intent) { |
| 842 Intent startIntent = AndroidListener.createStartIntent(getContext(), | 842 Intent startIntent = AndroidListener.createStartIntent(getContext(), |
| 843 InvalidationService.CLIENT_TYPE, "unused".getBytes()); | 843 InvalidationService.CLIENT_TYPE, "unused".getBytes()); |
| 844 return intent.getExtras().keySet().equals(startIntent.getExtras().keySet
()); | 844 return intent.getExtras().keySet().equals(startIntent.getExtras().keySet
()); |
| 845 } | 845 } |
| 846 | 846 |
| 847 /** Returns whether {@code intent} is an {@link AndroidListener} stop intent
. */ | 847 /** Returns whether {@code intent} is an {@link AndroidListener} stop intent
. */ |
| 848 private boolean isAndroidListenerStopIntent(Intent intent) { | 848 private boolean isAndroidListenerStopIntent(Intent intent) { |
| 849 Intent stopIntent = AndroidListener.createStopIntent(getContext()); | 849 Intent stopIntent = AndroidListener.createStopIntent(getContext()); |
| 850 return intent.getExtras().keySet().equals(stopIntent.getExtras().keySet(
)); | 850 return intent.getExtras().keySet().equals(stopIntent.getExtras().keySet(
)); |
| 851 } | 851 } |
| 852 } | 852 } |
| OLD | NEW |