blob: 02ed0edd87fb6277a6259e4e7b3f763b3d8556d1 [file] [log] [blame]
Neil Fuller2c6d5102019-11-29 09:02:39 +00001/*
2 * Copyright 2019 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.app.timezonedetector;
18
19import static android.app.timezonedetector.ParcelableTestSupport.assertRoundTripParcelable;
20import static android.app.timezonedetector.ParcelableTestSupport.roundTripParcelable;
21
22import static org.junit.Assert.assertEquals;
23import static org.junit.Assert.assertNotEquals;
24
25import org.junit.Test;
26
27public class ManualTimeZoneSuggestionTest {
28
29 private static final String ARBITRARY_ZONE_ID1 = "Europe/London";
30 private static final String ARBITRARY_ZONE_ID2 = "Europe/Paris";
31
32 @Test
33 public void testEquals() {
34 ManualTimeZoneSuggestion one = new ManualTimeZoneSuggestion(ARBITRARY_ZONE_ID1);
35 assertEquals(one, one);
36
37 ManualTimeZoneSuggestion two = new ManualTimeZoneSuggestion(ARBITRARY_ZONE_ID1);
38 assertEquals(one, two);
39 assertEquals(two, one);
40
41 ManualTimeZoneSuggestion three = new ManualTimeZoneSuggestion(ARBITRARY_ZONE_ID2);
42 assertNotEquals(one, three);
43 assertNotEquals(three, one);
44
45 // DebugInfo must not be considered in equals().
46 one.addDebugInfo("Debug info 1");
47 two.addDebugInfo("Debug info 2");
48 assertEquals(one, two);
49 }
50
51 @Test
52 public void testParcelable() {
53 ManualTimeZoneSuggestion suggestion = new ManualTimeZoneSuggestion(ARBITRARY_ZONE_ID1);
54 assertRoundTripParcelable(suggestion);
55
56 // DebugInfo should also be stored (but is not checked by equals()
57 suggestion.addDebugInfo("This is debug info");
58 ManualTimeZoneSuggestion rtSuggestion = roundTripParcelable(suggestion);
59 assertEquals(suggestion.getDebugInfo(), rtSuggestion.getDebugInfo());
60 }
61}