Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 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 | |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 17 | package org.onosproject.ui; |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 18 | |
| 19 | /** |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 20 | * Abstract base class for UI tests. |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 21 | */ |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 22 | public abstract class AbstractUiTest { |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * System agnostic end-of-line character. |
| 26 | */ |
| 27 | protected static final String EOL = String.format("%n"); |
| 28 | |
| 29 | /** |
Simon Hunt | c4ca710 | 2017-04-08 22:28:04 -0700 | [diff] [blame] | 30 | * Tolerance for Double equality assertions. |
| 31 | */ |
| 32 | protected static final double TOLERANCE = Double.MIN_VALUE * 2; |
| 33 | |
| 34 | /** |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 35 | * Prints the given string to stdout. |
| 36 | * |
| 37 | * @param s string to print |
| 38 | */ |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 39 | protected static void print(String s) { |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 40 | System.out.println(s); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Prints the toString() of the given object to stdout. |
| 45 | * |
| 46 | * @param o object to print |
| 47 | */ |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 48 | protected static void print(Object o) { |
| 49 | if (o == null) { |
| 50 | print("<null>"); |
| 51 | } else { |
| 52 | print(o.toString()); |
| 53 | } |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Prints the formatted string to stdout. |
| 58 | * |
| 59 | * @param fmt format string |
| 60 | * @param params parameters |
| 61 | * @see String#format(String, Object...) |
| 62 | */ |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 63 | protected static void print(String fmt, Object... params) { |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 64 | print(String.format(fmt, params)); |
| 65 | } |
| 66 | |
Simon Hunt | 642bc45 | 2016-05-04 19:34:45 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Prints a title, to delimit individual unit test output. |
| 69 | * |
| 70 | * @param s a title for the test |
| 71 | */ |
| 72 | protected static void title(String s) { |
| 73 | print(EOL + "=== %s ===", s); |
| 74 | } |
Simon Hunt | 338a3b4 | 2016-04-14 09:43:52 -0700 | [diff] [blame] | 75 | } |