Commit 60fb2a58 authored by kraush's avatar kraush Committed by Commit bot

Wait for async file creation in TabsTest

File creation of tab states is done in an async fashion.
TabsTest should correspondingly use a polling mechanism
to verify files are actually being created.

BUG=649429

Review-Url: https://codereview.chromium.org/2362793002
Cr-Commit-Position: refs/heads/master@{#420628}
parent ca5e49bc
......@@ -1694,8 +1694,8 @@ public class TabsTest extends ChromeTabbedActivityTestBase {
File incognitoTabFile = new File(tabStateDir,
TabState.getTabStateFilename(incognitoModel.getTabAt(0).getId(), true));
assertTrue(normalTabFile.getAbsolutePath(), normalTabFile.exists());
assertTrue(incognitoTabFile.getAbsolutePath(), incognitoTabFile.exists());
assertFileExists(normalTabFile, true);
assertFileExists(incognitoTabFile, true);
// Although we're destroying the activity, the Application will still live on since its in
// the same process as this test.
......@@ -1703,8 +1703,8 @@ public class TabsTest extends ChromeTabbedActivityTestBase {
// Activity will be started without a savedInstanceState.
startMainActivityOnBlankPage();
assertTrue(normalTabFile.exists());
assertFalse(incognitoTabFile.exists());
assertFileExists(normalTabFile, true);
assertFileExists(incognitoTabFile, false);
}
@Override
......@@ -1722,4 +1722,15 @@ public class TabsTest extends ChromeTabbedActivityTestBase {
}
startMainActivityFromLauncher();
}
private void assertFileExists(final File fileToCheck, final boolean expected)
throws InterruptedException {
CriteriaHelper.pollInstrumentationThread(
Criteria.equals(expected, new Callable<Boolean>() {
@Override
public Boolean call() {
return fileToCheck.exists();
}
}));
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment