View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
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    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertFalse;
19  import static org.junit.Assert.assertNotEquals;
20  import static org.junit.Assert.assertTrue;
21  
22  import java.util.TimeZone;
23  
24  import org.junit.Test;
25  
26  /**
27   * Tests for {@link BrowserVersion}.
28   *
29   * @author Ahmed Ashour
30   * @author Marc Guillemot
31   * @author Frank Danek
32   * @author Ronald Brill
33   */
34  public class BrowserVersionTest {
35  
36      /**
37       * Test of getBrowserVersionNumeric().
38       */
39      @Test
40      public void getBrowserVersionNumeric() {
41          assertEquals(138, BrowserVersion.FIREFOX.getBrowserVersionNumeric());
42          assertEquals(128, BrowserVersion.FIREFOX_ESR.getBrowserVersionNumeric());
43          assertEquals(136, BrowserVersion.CHROME.getBrowserVersionNumeric());
44          assertEquals(136, BrowserVersion.EDGE.getBrowserVersionNumeric());
45      }
46  
47      /**
48       * Test of {@link BrowserVersion#clone()}.
49       */
50      @Test
51      public void testClone() {
52          final BrowserVersion ff = BrowserVersion.FIREFOX;
53  
54          final BrowserVersion clone = new BrowserVersion.BrowserVersionBuilder(ff).build();
55  
56          // Nickname is used as key for dictionaries storing browser setups
57          assertTrue(ff.getNickname().equals(clone.getNickname()));
58  
59          assertFalse(ff == clone);
60          assertFalse(ff.equals(clone));
61      }
62  
63      /**
64       * Test of BrowserVersion.BrowserVersionBuilder.
65       */
66      @Test
67      public void differentTimeZone() {
68          final BrowserVersion ffBerlin = new BrowserVersion.BrowserVersionBuilder(BrowserVersion.FIREFOX)
69                                                  .setSystemTimezone(TimeZone.getTimeZone("Europe/Berlin"))
70                                                  .build();
71  
72          // Nickname is used as key for dictionaries storing browser setups
73          assertTrue(BrowserVersion.FIREFOX.getNickname().equals(ffBerlin.getNickname()));
74  
75          assertFalse(BrowserVersion.FIREFOX == ffBerlin);
76          assertFalse(BrowserVersion.FIREFOX.equals(ffBerlin));
77  
78          assertNotEquals(BrowserVersion.FIREFOX.getSystemTimezone(), ffBerlin.getSystemTimezone());
79      }
80  }