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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/tabmodel/RestoreMigrateTest.java

Issue 1000793002: [Android] Incorporate findbugs into android builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address cjhopman's comment + rebase Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.tabmodel; 5 package org.chromium.chrome.browser.tabmodel;
6 6
7 import android.test.InstrumentationTestCase; 7 import android.test.InstrumentationTestCase;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import org.chromium.base.ThreadUtils; 10 import org.chromium.base.ThreadUtils;
11 import org.chromium.base.annotations.SuppressFBWarnings;
11 import org.chromium.chrome.browser.TabState; 12 import org.chromium.chrome.browser.TabState;
12 import org.chromium.chrome.browser.util.StreamUtil; 13 import org.chromium.chrome.browser.util.StreamUtil;
13 import org.chromium.chrome.test.util.ApplicationData; 14 import org.chromium.chrome.test.util.ApplicationData;
14 import org.chromium.chrome.test.util.browser.tabmodel.MockTabModelSelector; 15 import org.chromium.chrome.test.util.browser.tabmodel.MockTabModelSelector;
15 16
16 import java.io.File; 17 import java.io.File;
17 import java.io.FileOutputStream; 18 import java.io.FileOutputStream;
18 import java.io.IOException; 19 import java.io.IOException;
19 import java.util.concurrent.Callable; 20 import java.util.concurrent.Callable;
20 import java.util.concurrent.ExecutionException; 21 import java.util.concurrent.ExecutionException;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return maxId; 54 return maxId;
54 } 55 }
55 56
56 /** 57 /**
57 * Test that normal migration of state files works. 58 * Test that normal migration of state files works.
58 * @throws IOException 59 * @throws IOException
59 * @throws InterruptedException 60 * @throws InterruptedException
60 * @throws ExecutionException 61 * @throws ExecutionException
61 */ 62 */
62 @SuppressWarnings("unused") 63 @SuppressWarnings("unused")
64 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
63 @SmallTest 65 @SmallTest
64 public void testMigrateData() throws IOException, InterruptedException, Exec utionException { 66 public void testMigrateData() throws IOException, InterruptedException, Exec utionException {
65 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 67 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
66 68
67 // Write old state files. 69 // Write old state files.
68 File filesDir = getInstrumentation().getTargetContext().getFilesDir(); 70 File filesDir = getInstrumentation().getTargetContext().getFilesDir();
69 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ; 71 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ;
70 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 "); 72 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 ");
71 File tab1 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "1 "); 73 File tab1 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "1 ");
72 File tab2 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX_INCO GNITO + "2"); 74 File tab2 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX_INCO GNITO + "2");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 110 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
109 } 111 }
110 112
111 /** 113 /**
112 * Test that migration skips if it already has files in the new folder. 114 * Test that migration skips if it already has files in the new folder.
113 * @throws IOException 115 * @throws IOException
114 * @throws InterruptedException 116 * @throws InterruptedException
115 * @throws ExecutionException 117 * @throws ExecutionException
116 */ 118 */
117 @SuppressWarnings("unused") 119 @SuppressWarnings("unused")
120 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
118 @SmallTest 121 @SmallTest
119 public void testSkipMigrateData() throws IOException, InterruptedException, ExecutionException { 122 public void testSkipMigrateData() throws IOException, InterruptedException, ExecutionException {
120 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 123 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
121 124
122 // Write old state files. 125 // Write old state files.
123 File filesDir = getInstrumentation().getTargetContext().getFilesDir(); 126 File filesDir = getInstrumentation().getTargetContext().getFilesDir();
124 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ; 127 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ;
125 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 "); 128 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 ");
126 File tab1 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "1 "); 129 File tab1 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "1 ");
127 File tab2 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX_INCO GNITO + "2"); 130 File tab2 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX_INCO GNITO + "2");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 168 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
166 } 169 }
167 170
168 /** 171 /**
169 * Test that the state file migration skips unrelated files. 172 * Test that the state file migration skips unrelated files.
170 * @throws IOException 173 * @throws IOException
171 * @throws InterruptedException 174 * @throws InterruptedException
172 * @throws ExecutionException 175 * @throws ExecutionException
173 */ 176 */
174 @SuppressWarnings("unused") 177 @SuppressWarnings("unused")
178 @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
175 @SmallTest 179 @SmallTest
176 public void testMigrationLeavesOtherFilesAlone() throws IOException, Interru ptedException, 180 public void testMigrationLeavesOtherFilesAlone() throws IOException, Interru ptedException,
177 ExecutionException { 181 ExecutionException {
178 ApplicationData.clearAppData(getInstrumentation().getTargetContext()); 182 ApplicationData.clearAppData(getInstrumentation().getTargetContext());
179 183
180 // Write old state files. 184 // Write old state files.
181 File filesDir = getInstrumentation().getTargetContext().getFilesDir(); 185 File filesDir = getInstrumentation().getTargetContext().getFilesDir();
182 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ; 186 File stateFile = new File(filesDir, TabPersistentStore.SAVED_STATE_FILE) ;
183 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 "); 187 File tab0 = new File(filesDir, TabState.SAVED_TAB_STATE_FILE_PREFIX + "0 ");
184 File otherFile = new File(filesDir, "other.file"); 188 File otherFile = new File(filesDir, "other.file");
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 TabPersistentStore storeIn1 = new TabPersistentStore(selectorIn1, 1, 258 TabPersistentStore storeIn1 = new TabPersistentStore(selectorIn1, 1,
255 getInstrumentation().getTargetContext(), null, null); 259 getInstrumentation().getTargetContext(), null, null);
256 260
257 storeIn0.loadStateInternal(); 261 storeIn0.loadStateInternal();
258 storeIn1.loadStateInternal(); 262 storeIn1.loadStateInternal();
259 263
260 assertEquals("Unexpected number of tabs to load", 6, storeIn0.getRestore dTabCount()); 264 assertEquals("Unexpected number of tabs to load", 6, storeIn0.getRestore dTabCount());
261 assertEquals("Unexpected number of tabst o load", 3, storeIn1.getRestore dTabCount()); 265 assertEquals("Unexpected number of tabst o load", 3, storeIn1.getRestore dTabCount());
262 266
263 } 267 }
264 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698