Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 1 | /* |
| 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 Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 19 | #include <binder/Binder.h> |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 20 | #include <binder/Parcel.h> |
| 21 | |
| 22 | #include <input/InputWindow.h> |
| 23 | #include <input/InputTransport.h> |
| 24 | |
| 25 | namespace android { |
| 26 | namespace test { |
| 27 | |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 28 | TEST(InputWindowInfo, ParcellingWithoutToken) { |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 29 | InputWindowInfo i; |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 30 | i.token = nullptr; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 31 | |
| 32 | Parcel p; |
| 33 | ASSERT_EQ(OK, i.write(p)); |
| 34 | p.setDataPosition(0); |
| 35 | InputWindowInfo i2 = InputWindowInfo::read(p); |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 36 | ASSERT_TRUE(i2.token == nullptr); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | TEST(InputWindowInfo, Parcelling) { |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 40 | InputWindowInfo i; |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 41 | i.token = new BBinder(); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 42 | 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; |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 50 | i.surfaceInset = 17; |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 51 | i.globalScaleFactor = 0.3; |
| 52 | i.windowXScale = 0.4; |
| 53 | i.windowYScale = 0.5; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 54 | i.visible = false; |
| 55 | i.canReceiveKeys = false; |
| 56 | i.hasFocus = false; |
| 57 | i.hasWallpaper = false; |
| 58 | i.paused = false; |
| 59 | i.layer = 7; |
| 60 | i.ownerPid = 19; |
| 61 | i.ownerUid = 24; |
| 62 | i.inputFeatures = 29; |
| 63 | i.displayId = 34; |
Tiger Huang | 85b8c5e | 2019-01-17 18:34:54 +0800 | [diff] [blame^] | 64 | i.portalToDisplayId = 2; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 65 | |
| 66 | Parcel p; |
| 67 | i.write(p); |
| 68 | |
| 69 | p.setDataPosition(0); |
| 70 | InputWindowInfo i2 = InputWindowInfo::read(p); |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 71 | ASSERT_EQ(i.token, i2.token); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 72 | ASSERT_EQ(i.name, i2.name); |
| 73 | ASSERT_EQ(i.layoutParamsFlags, i2.layoutParamsFlags); |
| 74 | ASSERT_EQ(i.layoutParamsType, i2.layoutParamsType); |
| 75 | ASSERT_EQ(i.dispatchingTimeout, i2.dispatchingTimeout); |
| 76 | ASSERT_EQ(i.frameLeft, i2.frameLeft); |
| 77 | ASSERT_EQ(i.frameTop, i2.frameTop); |
| 78 | ASSERT_EQ(i.frameRight, i2.frameRight); |
| 79 | ASSERT_EQ(i.frameBottom, i2.frameBottom); |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 80 | ASSERT_EQ(i.surfaceInset, i2.surfaceInset); |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 81 | ASSERT_EQ(i.globalScaleFactor, i2.globalScaleFactor); |
| 82 | ASSERT_EQ(i.windowXScale, i2.windowXScale); |
| 83 | ASSERT_EQ(i.windowYScale, i2.windowYScale); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 84 | ASSERT_EQ(i.visible, i2.visible); |
| 85 | ASSERT_EQ(i.canReceiveKeys, i2.canReceiveKeys); |
| 86 | ASSERT_EQ(i.hasFocus, i2.hasFocus); |
| 87 | ASSERT_EQ(i.hasWallpaper, i2.hasWallpaper); |
| 88 | ASSERT_EQ(i.paused, i2.paused); |
| 89 | ASSERT_EQ(i.layer, i2.layer); |
| 90 | ASSERT_EQ(i.ownerPid, i2.ownerPid); |
| 91 | ASSERT_EQ(i.ownerUid, i2.ownerUid); |
| 92 | ASSERT_EQ(i.inputFeatures, i2.inputFeatures); |
| 93 | ASSERT_EQ(i.displayId, i2.displayId); |
Tiger Huang | 85b8c5e | 2019-01-17 18:34:54 +0800 | [diff] [blame^] | 94 | ASSERT_EQ(i.portalToDisplayId, i2.portalToDisplayId); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | } // namespace test |
| 98 | } // namespace android |