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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistenceIntegrationTest.java

Issue 2520103002: Delete tab state files when the user explicitly closes a CCT. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistenceIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistenceIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistenceIntegrationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5e197a36b282270713fad03c3905f241263705b9
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/CustomTabTabPersistenceIntegrationTest.java
@@ -0,0 +1,60 @@
+// Copyright 2016 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.customtabs;
+
+import android.test.suitebuilder.annotation.MediumTest;
+
+import org.chromium.chrome.browser.TabState;
+import org.chromium.chrome.browser.UrlConstants;
+import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+
+import java.io.File;
+import java.util.Locale;
+
+/**
+ * Integration testing for the CustomTab Tab persistence logic.
+ */
+public class CustomTabTabPersistenceIntegrationTest extends CustomTabActivityTestBase {
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ super.startMainActivity();
+ startCustomTabActivityWithIntent(CustomTabsTestUtils.createMinimalCustomTabIntent(
+ getInstrumentation().getTargetContext(), UrlConstants.ABOUT_BLANK));
+ }
+
+ @MediumTest
+ public void testTabFilesDeletedOnClose() throws InterruptedException {
+ Tab tab = getActivity().getActivityTab();
+ String expectedTabFileName = TabState.getTabStateFilename(tab.getId(), false);
+ String expectedMetadataFileName =
+ getActivity().getTabPersistencePolicyForTest().getStateFileName();
+
+ File stateDir = getActivity().getTabPersistencePolicyForTest().getOrCreateStateDirectory();
+ waitForFileExistState(true, expectedTabFileName, stateDir);
+ waitForFileExistState(true, expectedMetadataFileName, stateDir);
+
+ getActivity().finishAndClose(false);
+
+ waitForFileExistState(false, expectedTabFileName, stateDir);
+ waitForFileExistState(false, expectedMetadataFileName, stateDir);
+ }
+
+ private void waitForFileExistState(
+ final boolean exists, final String fileName, final File filePath)
+ throws InterruptedException {
+ CriteriaHelper.pollInstrumentationThread(new Criteria(
+ String.format(Locale.US, "File, %s, expected to exist: %b", fileName, exists)) {
+ @Override
+ public boolean isSatisfied() {
+ File file = new File(filePath, fileName);
+ return file.exists() == exists;
+ }
+ });
+ }
+
+}
« no previous file with comments | « chrome/android/java_sources.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698