remove GoogleLoginService unit test
This now lives in the vendor/google directory alongside GoogleLoginService itself. Change-Id: Ic934fa563cdad965e5f95c2f6da407ea720bc0bf
This commit is contained in:
@@ -52,9 +52,6 @@
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SMS"/>
|
||||
<uses-permission android:name="com.android.unit_tests.permission.TEST_GRANTED" />
|
||||
<uses-permission android:name="com.google.android.googleapps.permission.ACCESS_GOOGLE_PASSWORD" />
|
||||
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
|
||||
<uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.ALL_SERVICES" />
|
||||
|
||||
<!-- InstrumentationTestRunner for AndroidTests -->
|
||||
<instrumentation android:name="android.test.InstrumentationTestRunner"
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
// Copyright 2008 The Android Open Source Project
|
||||
// All rights reserved.
|
||||
|
||||
package com.android.unit_tests;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.Suppress;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gsf.GoogleLoginCredentialsResult;
|
||||
import com.google.android.gsf.IGoogleLoginService;
|
||||
import com.google.android.gsf.GoogleLoginServiceConstants;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
// Suppress until bug http://b/issue?id=1416570 is fixed
|
||||
@Suppress
|
||||
/** Unit test for the Google login service. */
|
||||
public class GoogleLoginServiceTest extends AndroidTestCase {
|
||||
private static final String TAG = "GoogleLoginServiceTest";
|
||||
|
||||
private IGoogleLoginService mGls = null;
|
||||
private Lock mGlsLock = new ReentrantLock();
|
||||
private Condition mGlsCv = mGlsLock.newCondition();
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
mGlsLock.lock();
|
||||
try {
|
||||
mGls = IGoogleLoginService.Stub.asInterface(service);
|
||||
mGlsCv.signalAll();
|
||||
} finally {
|
||||
mGlsLock.unlock();
|
||||
}
|
||||
Log.v(TAG, "service is connected");
|
||||
}
|
||||
public void onServiceDisconnected(ComponentName className) {
|
||||
mGlsLock.lock();
|
||||
try {
|
||||
mGls = null;
|
||||
mGlsCv.signalAll();
|
||||
} finally {
|
||||
mGlsLock.unlock();
|
||||
}
|
||||
Log.v(TAG, "service is disconnected");
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
getContext().bindService((new Intent())
|
||||
.setClassName("com.google.android.gsf",
|
||||
"com.google.android.gsf.loginservice.GoogleLoginService"),
|
||||
mConnection, Context.BIND_AUTO_CREATE);
|
||||
|
||||
// wait for the service to cnnnect
|
||||
mGlsLock.lock();
|
||||
try {
|
||||
while (mGls == null) {
|
||||
try {
|
||||
mGlsCv.await();
|
||||
} catch (InterruptedException ignore) {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
mGlsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
getContext().unbindService(mConnection);
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testSingleAccountScheme() throws Exception {
|
||||
Assert.assertNotNull(mGls);
|
||||
mGls.deleteAllAccounts();
|
||||
|
||||
Assert.assertNull(mGls.getAccount(false));
|
||||
Assert.assertNull(mGls.getAccount(true));
|
||||
|
||||
mGls.saveUsernameAndPassword("vespa@gmail.com", "meow",
|
||||
GoogleLoginServiceConstants.FLAG_GOOGLE_ACCOUNT);
|
||||
Assert.assertEquals("vespa@gmail.com", mGls.getAccount(false));
|
||||
Assert.assertEquals("vespa@gmail.com", mGls.getAccount(true));
|
||||
|
||||
mGls.saveUsernameAndPassword("mackerel@hosted.com", "purr",
|
||||
GoogleLoginServiceConstants.FLAG_HOSTED_ACCOUNT);
|
||||
Assert.assertEquals("mackerel@hosted.com", mGls.getAccount(false));
|
||||
Assert.assertEquals("vespa@gmail.com", mGls.getAccount(true));
|
||||
}
|
||||
|
||||
public void listsEqual(String[] a, String[] b) {
|
||||
Assert.assertEquals(a.length, b.length);
|
||||
Arrays.sort(a);
|
||||
Arrays.sort(b);
|
||||
Assert.assertTrue(Arrays.equals(a, b));
|
||||
}
|
||||
|
||||
public void testAuthTokens() throws Exception {
|
||||
Assert.assertNotNull(mGls);
|
||||
mGls.deleteAllAccounts();
|
||||
|
||||
Assert.assertNull(mGls.peekCredentials("vespa@example.com", "mail"));
|
||||
|
||||
mGls.saveUsernameAndPassword("vespa@example.com", "meow",
|
||||
GoogleLoginServiceConstants.FLAG_HOSTED_ACCOUNT);
|
||||
Assert.assertNull(mGls.peekCredentials("vespa@example.com", "mail"));
|
||||
Assert.assertNull(mGls.peekCredentials(null, "mail"));
|
||||
|
||||
mGls.saveAuthToken("vespa@example.com", "mail", "1234");
|
||||
Assert.assertEquals("1234", mGls.peekCredentials("vespa@example.com", "mail"));
|
||||
Assert.assertEquals("1234", mGls.peekCredentials(null, "mail"));
|
||||
|
||||
mGls.saveUsernameAndPassword("mackerel@example.com", "purr",
|
||||
GoogleLoginServiceConstants.FLAG_GOOGLE_ACCOUNT);
|
||||
mGls.saveAuthToken("mackerel@example.com", "mail", "5678");
|
||||
Assert.assertEquals("1234", mGls.peekCredentials(null, "mail"));
|
||||
|
||||
mGls.saveAuthToken("mackerel@example.com", "mail", "8765");
|
||||
Assert.assertEquals("8765", mGls.peekCredentials("mackerel@example.com", "mail"));
|
||||
|
||||
GoogleLoginCredentialsResult r = mGls.blockingGetCredentials(
|
||||
"vespa@example.com", "mail", false);
|
||||
Assert.assertEquals("vespa@example.com", r.getAccount());
|
||||
Assert.assertEquals("1234", r.getCredentialsString());
|
||||
Assert.assertNull(r.getCredentialsIntent());
|
||||
|
||||
mGls.saveAuthToken("vespa@example.com", "cl", "abcd");
|
||||
Assert.assertEquals("1234", mGls.peekCredentials("vespa@example.com", "mail"));
|
||||
Assert.assertEquals("abcd", mGls.peekCredentials("vespa@example.com", "cl"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user