blob: ea98f8a302a99effc80f6b1efadc1287b221e54e [file] [log] [blame]
Robert Carr3720ed02018-08-08 16:08:27 -07001/*
2 * Copyright 2018 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#include <gtest/gtest.h>
18
Robert Carr5c8a0262018-10-03 16:30:44 -070019#include <binder/Binder.h>
Robert Carr3720ed02018-08-08 16:08:27 -070020#include <binder/Parcel.h>
21
22#include <input/InputWindow.h>
23#include <input/InputTransport.h>
24
25namespace android {
26namespace test {
27
Robert Carr5c8a0262018-10-03 16:30:44 -070028TEST(InputWindowInfo, ParcellingWithoutToken) {
Robert Carr3720ed02018-08-08 16:08:27 -070029 InputWindowInfo i;
Robert Carr5c8a0262018-10-03 16:30:44 -070030 i.token = nullptr;
Robert Carr3720ed02018-08-08 16:08:27 -070031
32 Parcel p;
33 ASSERT_EQ(OK, i.write(p));
34 p.setDataPosition(0);
35 InputWindowInfo i2 = InputWindowInfo::read(p);
Robert Carr5c8a0262018-10-03 16:30:44 -070036 ASSERT_TRUE(i2.token == nullptr);
Robert Carr3720ed02018-08-08 16:08:27 -070037}
38
39TEST(InputWindowInfo, Parcelling) {
Robert Carr3720ed02018-08-08 16:08:27 -070040 InputWindowInfo i;
Robert Carr5c8a0262018-10-03 16:30:44 -070041 i.token = new BBinder();
Robert Carr3720ed02018-08-08 16:08:27 -070042 i.name = "Foobar";
43 i.layoutParamsFlags = 7;
44 i.layoutParamsType = 39;
45 i.dispatchingTimeout = 12;
46 i.frameLeft = 93;
47 i.frameTop = 34;
48 i.frameRight = 16;
49 i.frameBottom = 19;
50 i.scaleFactor = 0.3;
51 i.visible = false;
52 i.canReceiveKeys = false;
53 i.hasFocus = false;
54 i.hasWallpaper = false;
55 i.paused = false;
56 i.layer = 7;
57 i.ownerPid = 19;
58 i.ownerUid = 24;
59 i.inputFeatures = 29;
60 i.displayId = 34;
61
62 Parcel p;
63 i.write(p);
64
65 p.setDataPosition(0);
66 InputWindowInfo i2 = InputWindowInfo::read(p);
Robert Carr5c8a0262018-10-03 16:30:44 -070067 ASSERT_EQ(i.token, i2.token);
Robert Carr3720ed02018-08-08 16:08:27 -070068 ASSERT_EQ(i.name, i2.name);
69 ASSERT_EQ(i.layoutParamsFlags, i2.layoutParamsFlags);
70 ASSERT_EQ(i.layoutParamsType, i2.layoutParamsType);
71 ASSERT_EQ(i.dispatchingTimeout, i2.dispatchingTimeout);
72 ASSERT_EQ(i.frameLeft, i2.frameLeft);
73 ASSERT_EQ(i.frameTop, i2.frameTop);
74 ASSERT_EQ(i.frameRight, i2.frameRight);
75 ASSERT_EQ(i.frameBottom, i2.frameBottom);
76 ASSERT_EQ(i.scaleFactor, i2.scaleFactor);
77 ASSERT_EQ(i.visible, i2.visible);
78 ASSERT_EQ(i.canReceiveKeys, i2.canReceiveKeys);
79 ASSERT_EQ(i.hasFocus, i2.hasFocus);
80 ASSERT_EQ(i.hasWallpaper, i2.hasWallpaper);
81 ASSERT_EQ(i.paused, i2.paused);
82 ASSERT_EQ(i.layer, i2.layer);
83 ASSERT_EQ(i.ownerPid, i2.ownerPid);
84 ASSERT_EQ(i.ownerUid, i2.ownerUid);
85 ASSERT_EQ(i.inputFeatures, i2.inputFeatures);
86 ASSERT_EQ(i.displayId, i2.displayId);
87}
88
89} // namespace test
90} // namespace android