MatrixTests.cpp revision 261725fdb2962271c222a049fcdf57bbdc8363c7
1261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik/*
2261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * Copyright (C) 2016 The Android Open Source Project
3261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik *
4261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * Licensed under the Apache License, Version 2.0 (the "License");
5261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * you may not use this file except in compliance with the License.
6261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * You may obtain a copy of the License at
7261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik *
8261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik *      http://www.apache.org/licenses/LICENSE-2.0
9261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik *
10261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * Unless required by applicable law or agreed to in writing, software
11261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * distributed under the License is distributed on an "AS IS" BASIS,
12261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * See the License for the specific language governing permissions and
14261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik * limitations under the License.
15261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik */
16261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik
17261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik#include <gtest/gtest.h>
18261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik
19261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik#include "Matrix.h"
20261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik#include "Rect.h"
21261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik
22261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craikusing namespace android::uirenderer;
23261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik
24261725fdb2962271c222a049fcdf57bbdc8363c7Chris CraikTEST(Matrix, mapRect) {
25261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    // Skew, so we don't hit identity/translate/simple fast paths
26261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    Matrix4 matrix;
27261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    matrix.skew(0.1f, 0.1f);
28261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik
29261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    // non-zero empty rect, so sorting x/y would make rect non-empty
30261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    Rect empty(100, 100, -100, -100);
31261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    ASSERT_TRUE(empty.isEmpty());
32261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    matrix.mapRect(empty);
33261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik    EXPECT_TRUE(empty.isEmpty())
34261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik        << "Empty rect should always remain empty, regardless of mapping.";
35261725fdb2962271c222a049fcdf57bbdc8363c7Chris Craik}
36