Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragmentTest.java

Issue 2900173002: Copy and view saved passwords. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/junit/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragmentTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragmentTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragmentTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ff11c46ffe4cb162b856331d86eab784700a72bd
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/preferences/password/PasswordReauthenticationFragmentTest.java
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.preferences.password;
+
+import static org.junit.Assert.assertEquals;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.Intent;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
+/**
+ * Tests for the "Save Passwords" settings screen.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+public class PasswordReauthenticationFragmentTest {
+ /**
+ * Ensure that upon reauthentication PasswordReauthenticationFragment is popped from
+ * the FragmentManager backstack.
+ */
+ @Test
+ public void testOnActivityResult() {
+ PasswordReauthenticationFragment sMockPasswordReauthentication =
gone 2017/06/01 20:46:38 s is only used for static variables
melandory 2017/06/09 15:09:28 Done.
+ new PasswordReauthenticationFragment();
+
+ // Replacement fragment for PasswordEntryEditor, which is the fragment that
+ // replaces PasswordReauthentication after popBackStack is called.
+ Fragment sMockPasswordEntryEditor = new Fragment();
gone 2017/06/01 20:46:38 s is only used for static variables
melandory 2017/06/09 15:09:28 Done.
+
+ Activity mTestActivity = Robolectric.setupActivity(Activity.class);
gone 2017/06/01 20:46:38 m is only used for member variables
melandory 2017/06/09 15:09:28 Done.
+ Intent returnIntent = new Intent();
+ returnIntent.putExtra("result", "This is the result");
+ sMockPasswordReauthentication.preventLockingForTesting(true);
+
+ FragmentManager fragmentManager = mTestActivity.getFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.add(sMockPasswordEntryEditor, "password_entry_editor");
+ fragmentTransaction.addToBackStack("add_password_entry_editor");
+ fragmentTransaction.commit();
+
+ FragmentTransaction fragmentTransaction2 = fragmentManager.beginTransaction();
+ fragmentTransaction2.add(sMockPasswordReauthentication, "password_reauthentication");
+ fragmentTransaction2.addToBackStack("add_password_reauthentication");
+ fragmentTransaction2.commit();
+
+ sMockPasswordReauthentication.onActivityResult(
+ PasswordReauthenticationFragment.CONFIRM_DEVICE_CREDENTIAL_REQUEST_CODE,
+ mTestActivity.RESULT_OK, returnIntent);
+ fragmentManager.executePendingTransactions();
+
+ // Assert that the number of fragments in the Back Stack is equal to 1 after
+ // reauthentication, as PasswordReauthenticationFragment is popped.
+ assertEquals(1, fragmentManager.getBackStackEntryCount());
+
+ // Assert that the remaining fragment in the Back Stack is PasswordEntryEditor.
+ assertEquals("add_password_entry_editor", fragmentManager.getBackStackEntryAt(0).getName());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698