| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; | 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; |
| 8 | 8 |
| 9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
| 10 import android.content.pm.ActivityInfo; | 10 import android.content.pm.ActivityInfo; |
| (...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1798 } | 1798 } |
| 1799 }); | 1799 }); |
| 1800 | 1800 |
| 1801 assertTrue("WebContentsObserver was never destroyed", webContentsDestroy
Called.get()); | 1801 assertTrue("WebContentsObserver was never destroyed", webContentsDestroy
Called.get()); |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 @MediumTest | 1804 @MediumTest |
| 1805 @Feature({"Android-TabSwitcher"}) | 1805 @Feature({"Android-TabSwitcher"}) |
| 1806 @RetryOnFailure | 1806 @RetryOnFailure |
| 1807 public void testIncognitoTabsNotRestoredAfterSwipe() throws Exception { | 1807 public void testIncognitoTabsNotRestoredAfterSwipe() throws Exception { |
| 1808 mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation
().getContext()); |
| 1809 startMainActivityWithURL(mTestServer.getURL(TEST_PAGE_FILE_PATH)); |
| 1810 |
| 1808 newIncognitoTabFromMenu(); | 1811 newIncognitoTabFromMenu(); |
| 1812 // Tab states are not saved for empty NTP tabs, so navigate to any page
to trigger a file |
| 1813 // to be saved. |
| 1814 loadUrl(mTestServer.getURL(TEST_PAGE_FILE_PATH)); |
| 1809 | 1815 |
| 1810 File tabStateDir = TabbedModeTabPersistencePolicy.getOrCreateTabbedModeS
tateDirectory(); | 1816 File tabStateDir = TabbedModeTabPersistencePolicy.getOrCreateTabbedModeS
tateDirectory(); |
| 1811 TabModel normalModel = getActivity().getTabModelSelector().getModel(fals
e); | 1817 TabModel normalModel = getActivity().getTabModelSelector().getModel(fals
e); |
| 1812 TabModel incognitoModel = getActivity().getTabModelSelector().getModel(t
rue); | 1818 TabModel incognitoModel = getActivity().getTabModelSelector().getModel(t
rue); |
| 1813 File normalTabFile = new File(tabStateDir, | 1819 File normalTabFile = new File(tabStateDir, |
| 1814 TabState.getTabStateFilename( | 1820 TabState.getTabStateFilename( |
| 1815 normalModel.getTabAt(normalModel.getCount() - 1).getId()
, false)); | 1821 normalModel.getTabAt(normalModel.getCount() - 1).getId()
, false)); |
| 1816 File incognitoTabFile = new File(tabStateDir, | 1822 File incognitoTabFile = new File(tabStateDir, |
| 1817 TabState.getTabStateFilename(incognitoModel.getTabAt(0).getId(),
true)); | 1823 TabState.getTabStateFilename(incognitoModel.getTabAt(0).getId(),
true)); |
| 1818 | 1824 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1832 @Override | 1838 @Override |
| 1833 public void startMainActivity() throws InterruptedException { | 1839 public void startMainActivity() throws InterruptedException { |
| 1834 float dpToPx = getInstrumentation().getContext().getResources().getDispl
ayMetrics().density; | 1840 float dpToPx = getInstrumentation().getContext().getResources().getDispl
ayMetrics().density; |
| 1835 mPxToDp = 1.0f / dpToPx; | 1841 mPxToDp = 1.0f / dpToPx; |
| 1836 | 1842 |
| 1837 // Exclude the tests that can launch directly to a page other than the N
TP. | 1843 // Exclude the tests that can launch directly to a page other than the N
TP. |
| 1838 if (getName().equals("testOpenAndCloseNewTabButton") | 1844 if (getName().equals("testOpenAndCloseNewTabButton") |
| 1839 || getName().equals("testSwitchToTabThatDoesNotHaveThumbnail") | 1845 || getName().equals("testSwitchToTabThatDoesNotHaveThumbnail") |
| 1840 || getName().equals("testCloseTabPortrait") | 1846 || getName().equals("testCloseTabPortrait") |
| 1841 || getName().equals("testCloseTabLandscape") | 1847 || getName().equals("testCloseTabLandscape") |
| 1842 || getName().equals("testTabsAreDestroyedOnModelDestruction")) { | 1848 || getName().equals("testTabsAreDestroyedOnModelDestruction") |
| 1849 || getName().equals("testIncognitoTabsNotRestoredAfterSwipe")) { |
| 1843 return; | 1850 return; |
| 1844 } | 1851 } |
| 1845 startMainActivityFromLauncher(); | 1852 startMainActivityFromLauncher(); |
| 1846 } | 1853 } |
| 1847 | 1854 |
| 1848 private void assertFileExists(final File fileToCheck, final boolean expected
) | 1855 private void assertFileExists(final File fileToCheck, final boolean expected
) |
| 1849 throws InterruptedException { | 1856 throws InterruptedException { |
| 1850 CriteriaHelper.pollInstrumentationThread( | 1857 CriteriaHelper.pollInstrumentationThread( |
| 1851 Criteria.equals(expected, new Callable<Boolean>() { | 1858 Criteria.equals(expected, new Callable<Boolean>() { |
| 1852 @Override | 1859 @Override |
| 1853 public Boolean call() { | 1860 public Boolean call() { |
| 1854 return fileToCheck.exists(); | 1861 return fileToCheck.exists(); |
| 1855 } | 1862 } |
| 1856 })); | 1863 })); |
| 1857 } | 1864 } |
| 1858 } | 1865 } |
| OLD | NEW |