1 /*
2  * Copyright (C) 2024 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 
17 package android.os.connectivity.cts;
18 
19 import static com.google.common.truth.Truth.assertThat;
20 
21 import android.os.Parcel;
22 import android.os.connectivity.WifiActivityEnergyInfo;
23 
24 import org.junit.Test;
25 
26 public class WifiActivityEnergyInfoTest {
27 
28     @Test
parceling()29     public void parceling() {
30         WifiActivityEnergyInfo info = new WifiActivityEnergyInfo(100,
31                 WifiActivityEnergyInfo.STACK_STATE_STATE_ACTIVE, 200, 300, 400, 500);
32 
33         Parcel out = Parcel.obtain();
34         info.writeToParcel(out, 0);
35         byte[] bytes = out.marshall();
36 
37         Parcel in = Parcel.obtain();
38         in.unmarshall(bytes, 0, bytes.length);
39         in.setDataPosition(0);
40 
41         WifiActivityEnergyInfo actual = WifiActivityEnergyInfo.CREATOR.createFromParcel(in);
42         assertThat(actual.getTimeSinceBootMillis()).isEqualTo(100);
43         assertThat(actual.getStackState()).isEqualTo(
44                 WifiActivityEnergyInfo.STACK_STATE_STATE_ACTIVE);
45         assertThat(actual.getControllerTxDurationMillis()).isEqualTo(200);
46         assertThat(actual.getControllerRxDurationMillis()).isEqualTo(300);
47         assertThat(actual.getControllerScanDurationMillis()).isEqualTo(400);
48         assertThat(actual.getControllerIdleDurationMillis()).isEqualTo(500);
49     }
50 }
51