1 /* 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 package com.android.managedprovisioning.uiflows; 17 18 import android.content.Intent; 19 import android.test.ActivityUnitTestCase; 20 import android.test.suitebuilder.annotation.SmallTest; 21 import android.view.ViewGroup; 22 import android.webkit.WebView; 23 24 @SmallTest 25 public class WebActivityTest extends ActivityUnitTestCase<WebActivity> { 26 private static final String TEST_URL = "http://www.test.com/support"; 27 28 public WebActivityTest() { 29 super(WebActivity.class); 30 } 31 32 public void testNoUrl() { 33 startActivity(WebActivity.createIntent(getInstrumentation().getTargetContext(), 34 null, null), null, null); 35 assertTrue(isFinishCalled()); 36 } 37 38 public void testUrlLaunched() { 39 startActivity(WebActivity.createIntent(getInstrumentation().getTargetContext(), 40 TEST_URL, null), null, null); 41 assertFalse(isFinishCalled()); 42 WebView webView = (WebView) ((ViewGroup) getActivity().findViewById(android.R.id.content)) 43 .getChildAt(0); 44 assertEquals(TEST_URL, webView.getUrl()); 45 } 46 } 47