From dc8ca50a2476c17880b7ed66836487ded42b83a5 Mon Sep 17 00:00:00 2001 From: Benjamin Wulfe Date: Mon, 8 Dec 2014 10:35:36 -0500 Subject: Adds support for unit tests. Change-Id: I8bf64d67bb3c3bae240c478c0e45ad5d5110fd88 --- testSrc/com/google/gct/login/MockGoogleLogin.java | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 testSrc/com/google/gct/login/MockGoogleLogin.java (limited to 'testSrc') diff --git a/testSrc/com/google/gct/login/MockGoogleLogin.java b/testSrc/com/google/gct/login/MockGoogleLogin.java new file mode 100644 index 0000000..d17652c --- /dev/null +++ b/testSrc/com/google/gct/login/MockGoogleLogin.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.gct.login; + +import org.mockito.Mockito; + +import java.io.*; + +/** + * Helper to install a mock googleLogin + */ +public class MockGoogleLogin { + GoogleLogin myGoogleLogin; + + public void install() { + myGoogleLogin = GoogleLogin.getInstance(); + GoogleLogin.setInstance(Mockito.mock(GoogleLogin.class)); + } + + public void cleanup() { + GoogleLogin.setInstance(myGoogleLogin); + } +} -- cgit v1.2.3