1bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur/* 2bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * Copyright (C) 2017 Google Inc. 3bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * 4bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * Licensed under the Apache License, Version 2.0 (the "License"); 5bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * you may not use this file except in compliance with the License. 6bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * You may obtain a copy of the License at 7bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * 8bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * http://www.apache.org/licenses/LICENSE-2.0 9bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * 10bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * Unless required by applicable law or agreed to in writing, software 11bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * distributed under the License is distributed on an "AS IS" BASIS, 12bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * See the License for the specific language governing permissions and 14bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur * limitations under the License. 15bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur */ 16bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 17bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurpackage com.android.settings.password; 18bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 19bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport static org.junit.Assert.assertEquals; 20bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport static org.junit.Assert.assertNotNull; 21bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport static org.robolectric.RuntimeEnvironment.application; 22bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 23bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport android.app.Activity; 24bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport android.app.AlertDialog; 25bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 26bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.R; 27bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.TestConfig; 28bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.testutils.SettingsRobolectricTestRunner; 29bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.testutils.shadow.SettingsShadowResources; 30bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.testutils.shadow.ShadowEventLogWriter; 31bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport com.android.settings.testutils.shadow.ShadowUtils; 32bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 33bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.junit.Before; 34bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.junit.Test; 35bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.junit.runner.RunWith; 36bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.robolectric.Robolectric; 37bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.robolectric.Shadows; 38bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.robolectric.annotation.Config; 39bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurimport org.robolectric.shadows.ShadowAlertDialog; 40bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 41bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur@RunWith(SettingsRobolectricTestRunner.class) 42e3535d9998363cbf352b5f8feb9277475e380944Fan Zhang@Config(manifest = TestConfig.MANIFEST_PATH, 43bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur sdk = TestConfig.SDK_VERSION, 44bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur shadows = { 45bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur SettingsShadowResources.class, 46bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur SettingsShadowResources.SettingsShadowTheme.class, 47bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur ShadowEventLogWriter.class, 48bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur ShadowUtils.class 49bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur }) 50bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathurpublic class SetupSkipDialogTest { 51bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 52bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur private Activity mActivity; 53bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 54bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur @Before 55bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur public void setUp() { 56bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur mActivity = Robolectric.setupActivity(Activity.class); 57bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur } 58bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 59bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur @Test 60bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur public void frpMessages_areShownCorrectly_whenNotSupported() { 61bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(false); 62bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur setupSkipDialog.show(mActivity.getFragmentManager()); 63bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 64bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog(); 65bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertNotNull(alertDialog); 66bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog); 67bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertEquals(application.getString(R.string.lock_screen_intro_skip_title), 68bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur shadowAlertDialog.getTitle()); 69bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertEquals(application.getString(R.string.lock_screen_intro_skip_dialog_text), 70bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur shadowAlertDialog.getMessage()); 71bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur } 72bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 73bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur @Test 74bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur public void frpMessages_areShownCorrectly_whenSupported() { 75bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur SetupSkipDialog setupSkipDialog = SetupSkipDialog.newInstance(true); 76bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur setupSkipDialog.show(mActivity.getFragmentManager()); 77bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 78bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur AlertDialog alertDialog = ShadowAlertDialog.getLatestAlertDialog(); 79bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertNotNull(alertDialog); 80bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur ShadowAlertDialog shadowAlertDialog = Shadows.shadowOf(alertDialog); 81bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertEquals(application.getString(R.string.lock_screen_intro_skip_title), 82bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur shadowAlertDialog.getTitle()); 83bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur assertEquals(application.getString(R.string.lock_screen_intro_skip_dialog_text_frp), 84bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur shadowAlertDialog.getMessage()); 85bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur } 86bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur 87bf3a1351708bf3aeeac160dd7211c4bc4d3ac79bAjay Nadathur} 88