1/*
2 * Copyright (C) 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
17package android.graphics;
18
19import static android.graphics.Rect.copyOrNull;
20
21import static org.junit.Assert.assertEquals;
22import static org.junit.Assert.assertNotSame;
23import static org.junit.Assert.assertNull;
24
25import android.platform.test.annotations.Presubmit;
26import android.support.test.filters.SmallTest;
27import android.support.test.runner.AndroidJUnit4;
28
29import org.junit.Test;
30import org.junit.runner.RunWith;
31
32@RunWith(AndroidJUnit4.class)
33@SmallTest
34@Presubmit
35public class RectTest {
36
37    @Test
38    public void copyOrNull_passesThroughNull() {
39        assertNull(copyOrNull(null));
40    }
41
42    @Test
43    public void copyOrNull_copiesNonNull() {
44        final Rect orig = new Rect(1, 2, 3, 4);
45        final Rect copy = copyOrNull(orig);
46
47        assertEquals(orig, copy);
48        assertNotSame(orig, copy);
49    }
50}
51