Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/BaseJsTest.java

Issue 29347192: Issue 4181 - Fix FilterEngineTest tests (Closed)
Left Patch Set: Changes with applied Eyeo's codestyle (2-space indentation) Created Aug. 8, 2016, 7:51 a.m.
Right Patch Set: marked method as static Created Dec. 2, 2016, 6:14 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 13 matching lines...) Expand all
24 24
25 import android.test.AndroidTestCase; 25 import android.test.AndroidTestCase;
26 26
27 import java.io.File; 27 import java.io.File;
28 import java.io.IOException; 28 import java.io.IOException;
29 29
30 public abstract class BaseJsTest extends AndroidTestCase 30 public abstract class BaseJsTest extends AndroidTestCase
31 { 31 {
32 protected JsEngine jsEngine; 32 protected JsEngine jsEngine;
33 protected File tmpFileSystemPath; 33 protected File tmpFileSystemPath;
34 protected FileSystemUtils fileSystemUtils = new FileSystemUtils(); 34
35
36 protected File buildTmpFileSystemPath() throws IOException 35 protected File buildTmpFileSystemPath() throws IOException
37 { 36 {
38 File tmpFileSystemPath = fileSystemUtils 37 File tmpFileSystemPath = FileSystemUtils
39 .generateUniqueFileName(null, ".fs", getContext().getCacheDir()); 38 .generateUniqueFile(null, ".fs", getContext().getCacheDir());
40 tmpFileSystemPath.mkdirs(); 39 tmpFileSystemPath.mkdirs();
41 return tmpFileSystemPath; 40 return tmpFileSystemPath;
42 } 41 }
43 42
44 @Override 43 @Override
45 protected void setUp() throws Exception 44 protected void setUp() throws Exception
46 { 45 {
47 super.setUp(); 46 super.setUp();
48 47
49 jsEngine = new JsEngine(AppInfo.builder().build()); 48 jsEngine = new JsEngine(AppInfo.builder().build());
50 jsEngine.setDefaultLogSystem(); 49 jsEngine.setDefaultLogSystem();
51 50
52 // we need to generate new file system path in order 51 // we need to generate new file system path in order
53 // not to have JsEngine state from the previous test 52 // not to have JsEngine state from the previous test
54 tmpFileSystemPath = buildTmpFileSystemPath(); 53 tmpFileSystemPath = buildTmpFileSystemPath();
55 jsEngine.setDefaultFileSystem(tmpFileSystemPath.getAbsolutePath()); 54 jsEngine.setDefaultFileSystem(tmpFileSystemPath.getAbsolutePath());
56 jsEngine.setWebRequest(new ThrowingWebRequest()); 55 jsEngine.setWebRequest(new ThrowingWebRequest());
57 } 56 }
58 57
59 protected void cleanupFileSystem() 58 protected void cleanupFileSystem()
60 { 59 {
61 if (tmpFileSystemPath != null && tmpFileSystemPath.exists()) 60 if (tmpFileSystemPath != null && tmpFileSystemPath.exists())
62 { 61 {
63 fileSystemUtils.delete(tmpFileSystemPath, true); 62 FileSystemUtils.delete(tmpFileSystemPath, true);
64 tmpFileSystemPath = null; 63 tmpFileSystemPath = null;
65 } 64 }
66 } 65 }
67 66
68 @Override 67 @Override
69 protected void tearDown() throws Exception 68 protected void tearDown() throws Exception
70 { 69 {
71 cleanupFileSystem(); 70 cleanupFileSystem();
72 super.tearDown(); 71 super.tearDown();
73 } 72 }
74 } 73 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld