blob: d4233b286460212d77bf88ef8e2a5abdfb43db93 [file] [log] [blame]
Ta-wei Yenb250ce82016-06-07 15:16:30 -07001/*
2 * Copyright (C) 2016 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
17
18package com.android.phone;
19
20import android.os.Looper;
21
22/**
23 * Assertions which will result in program termination.
24 */
25public class Assert {
26
27 public static void isTrue(boolean condition) {
28 if (!condition) {
29 throw new AssertionError("Expected condition to be true");
30 }
31 }
32
33 public static void isNotMainThread() {
34 isTrue(!Looper.getMainLooper().equals(Looper.myLooper()));
35 }
36
37 public static void fail() {
38 throw new AssertionError("Fail");
39 }
40}