replicant-packages_apps_Email/tests/src/com/android/exchange/SyncManagerTest.java
Makoto Onuki 12b4bc9e80 Show device id on the exchange setting screen.
I've attached a screenshot on the referenced bug.

Also fixed a bug in SyncManager.getDeviceId() where sDeviceId cache wasn't
working.

Bug 2591124

Change-Id: I4b58517c095a96d47fb57179d70091b2c7af5249
2010-04-13 17:10:26 -07:00

60 lines
1.9 KiB
Java

/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.exchange;
import android.content.Context;
import android.content.ContextWrapper;
import android.test.AndroidTestCase;
import java.io.File;
public class SyncManagerTest extends AndroidTestCase {
private static class MyContext extends ContextWrapper {
public boolean isGetFileStreamPathCalled;
public MyContext(Context base) {
super(base);
}
@Override
public File getFileStreamPath(String name) {
isGetFileStreamPathCalled = true;
return super.getFileStreamPath(name);
}
}
public void testGetDeviceId() throws Exception {
final MyContext context = new MyContext(getContext());
final String id = SyncManager.getDeviceId(context);
// Consists of alpha-numeric
assertTrue(id.matches("^[a-zA-Z0-9]+$"));
// getDeviceId may have been called in other tests, so we don't check
// isGetFileStreamPathCalled here.
context.isGetFileStreamPathCalled = false;
final String cachedId = SyncManager.getDeviceId(context);
// Should be the same.
assertEquals(id, cachedId);
// Should be cached. (If cached, this method won't be called.)
assertFalse(context.isGetFileStreamPathCalled);
}
}