1 /* 2 * Copyright (C) 2008 The Android Open Source Project 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 */ 16 package android.app.cts; 17 18 import java.util.List; 19 20 import android.app.ActivityManager; 21 import android.app.ActivityManager.RunningAppProcessInfo; 22 import android.content.Context; 23 import android.os.Parcel; 24 import android.test.AndroidTestCase; 25 26 27 public class ActivityManager_RunningAppProcessInfoTest extends AndroidTestCase { 28 29 public void testRunningAppProcessInfo() { 30 // test constructor 31 new RunningAppProcessInfo(); 32 new RunningAppProcessInfo("test", 100, new String[]{"com.android", "com.android.test"}); 33 34 final ActivityManager am = (ActivityManager) 35 getContext().getSystemService(Context.ACTIVITY_SERVICE); 36 final List<RunningAppProcessInfo> list = am.getRunningAppProcesses(); 37 final RunningAppProcessInfo rap = list.get(0); 38 39 // test describeContents function 40 assertEquals(0, rap.describeContents()); 41 final Parcel p = Parcel.obtain(); 42 43 // test writeToParcel function 44 rap.writeToParcel(p, 0); 45 46 // test readFromParcel function 47 final RunningAppProcessInfo r = new RunningAppProcessInfo(); 48 p.setDataPosition(0); 49 r.readFromParcel(p); 50 51 assertEquals(rap.pid, r.pid); 52 assertEquals(rap.processName, r.processName); 53 assertEquals(rap.pkgList.length, r.pkgList.length); 54 55 for (int i = 0; i < rap.pkgList.length; i++) { 56 assertEquals(rap.pkgList[i], r.pkgList[i]); 57 } 58 } 59 60 } 61