Fix crashing tests
Some of the tests are still failing, but at least now we can go through till the end. - Fixed NPE in WelcomeTests (caused by the mock context not returning a proper layout inflator.) - Removed the rainy day test from MessageFileViewTest. (Not setting a proper intent will result in the argument check in MessageFileViewFragment) - Removed unnecessary null check in EmailProvider.getDatabase() Bug 4766072 Change-Id: I48b92cc91d0417cd9980c131fda8f63a9a6eb990
This commit is contained in:
parent
09a0e9b5dc
commit
369905c95d
@ -50,10 +50,10 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
if (mFileEmailUri == null) { // sanity check. setFileUri() must have been called.
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -763,22 +763,18 @@ public class EmailProvider extends ContentProvider {
|
||||
|
||||
DatabaseHelper helper = new DatabaseHelper(context, DATABASE_NAME);
|
||||
mDatabase = helper.getWritableDatabase();
|
||||
if (mDatabase != null) {
|
||||
mDatabase.setLockingEnabled(true);
|
||||
BodyDatabaseHelper bodyHelper = new BodyDatabaseHelper(context, BODY_DATABASE_NAME);
|
||||
mBodyDatabase = bodyHelper.getWritableDatabase();
|
||||
if (mBodyDatabase != null) {
|
||||
mBodyDatabase.setLockingEnabled(true);
|
||||
String bodyFileName = mBodyDatabase.getPath();
|
||||
mDatabase.execSQL("attach \"" + bodyFileName + "\" as BodyDatabase");
|
||||
}
|
||||
|
||||
// Restore accounts if the database is corrupted...
|
||||
restoreIfNeeded(context, mDatabase);
|
||||
} else {
|
||||
Log.w(TAG, "getWritableDatabase returned null!");
|
||||
mDatabase.setLockingEnabled(true);
|
||||
BodyDatabaseHelper bodyHelper = new BodyDatabaseHelper(context, BODY_DATABASE_NAME);
|
||||
mBodyDatabase = bodyHelper.getWritableDatabase();
|
||||
if (mBodyDatabase != null) {
|
||||
mBodyDatabase.setLockingEnabled(true);
|
||||
String bodyFileName = mBodyDatabase.getPath();
|
||||
mDatabase.execSQL("attach \"" + bodyFileName + "\" as BodyDatabase");
|
||||
}
|
||||
|
||||
// Restore accounts if the database is corrupted...
|
||||
restoreIfNeeded(context, mDatabase);
|
||||
|
||||
// Check for any orphaned Messages in the updated/deleted tables
|
||||
deleteOrphans(mDatabase, Message.UPDATED_TABLE_NAME);
|
||||
deleteOrphans(mDatabase, Message.DELETED_TABLE_NAME);
|
||||
|
@ -206,6 +206,14 @@ public final class DBTestHelper {
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
return new MockSharedPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSystemService(String name) {
|
||||
if (Context.LAYOUT_INFLATER_SERVICE.equals(name)) {
|
||||
return mRealContext.getSystemService(name);
|
||||
}
|
||||
return super.getSystemService(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,24 +54,6 @@ public class MessageFileViewTest extends ActivityInstrumentationTestCase2<Messag
|
||||
setActivityIntent(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open the activity without setting an Intent.
|
||||
*
|
||||
* Expected: Activity will close itself.
|
||||
*/
|
||||
public void testCreateWithoutParamter() throws Throwable {
|
||||
// No intent parameters specified. The activity will close itself.
|
||||
final MessageFileView activity = getActivity();
|
||||
|
||||
TestUtils.waitUntil("", new TestUtils.Condition() {
|
||||
@Override
|
||||
public boolean isMet() {
|
||||
return activity.isFinishing();
|
||||
}
|
||||
}, TIMEOUT);
|
||||
}
|
||||
|
||||
private Uri createEmlFile() throws Exception {
|
||||
// Create a simple message
|
||||
Message msg = new Message();
|
||||
|
Loading…
Reference in New Issue
Block a user