AccountTests.java revision 9ace18a77e1c61700291f6116bb8162c8fce1fad
1/**
2 * Copyright (c) 2012, Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.mail.providers;
17
18import android.content.Intent;
19import android.os.Parcel;
20import android.test.AndroidTestCase;
21
22import com.android.mail.utils.Utils;
23
24public class AccountTests extends AndroidTestCase {
25
26    public void testSerializeDeSerialize() {
27        Parcel dest = Parcel.obtain();
28        dest.writeInt(0);
29        dest.writeString("accountUri");
30        dest.writeInt(12345);
31        dest.writeString("foldersList");
32        dest.writeString("searchUri");
33        dest.writeString("fromAddresses");
34        dest.writeString("saveDraftUri");
35        dest.writeString("sendMessageUri");
36        dest.writeString("expungeMessageUri");
37        dest.writeString("undoUri");
38        dest.writeString("settingIntentUri");
39        dest.writeInt(0);
40        Account account = new Account(dest);
41        Intent intent = new Intent();
42        intent.putExtra(Utils.EXTRA_ACCOUNT, account);
43        Account outAccount = (Account) intent.getParcelableExtra(Utils.EXTRA_ACCOUNT);
44        assertEquals(outAccount.name, account.name);
45        assertEquals(outAccount.accountFromAddressesUri, account.accountFromAddressesUri);
46        assertEquals(outAccount.capabilities, account.capabilities);
47        assertEquals(outAccount.providerVersion, account.providerVersion);
48        assertEquals(outAccount.accountUri, account.accountUri);
49        assertEquals(outAccount.folderListUri, account.folderListUri);
50        assertEquals(outAccount.searchUri, account.searchUri);
51        assertEquals(outAccount.saveDraftUri, account.saveDraftUri);
52        assertEquals(outAccount.sendMessageUri, account.sendMessageUri);
53        assertEquals(outAccount.expungeMessageUri, account.expungeMessageUri);
54    }
55}