Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / base / android / javatests / src / org / chromium / base / LibraryLoaderHelperTest.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.base;
6
7 import android.content.Context;
8 import android.test.InstrumentationTestCase;
9 import android.test.suitebuilder.annotation.MediumTest;
10
11 import org.chromium.base.library_loader.LibraryLoaderHelper;
12
13 import java.io.File;
14
15 /**
16  * Test class for the native library hack.
17  */
18 public class LibraryLoaderHelperTest extends InstrumentationTestCase {
19     private static final String TAG = "LibraryLoaderHelperTest";
20
21     @Override
22     public void setUp() throws Exception {
23         Context context = getInstrumentation().getTargetContext();
24         LibraryLoaderHelper.deleteLibrariesSynchronously(
25                 context, LibraryLoaderHelper.PACKAGE_MANAGER_WORKAROUND_DIR);
26     }
27
28     @MediumTest
29     public void testLoadNativeLibraries() {
30         getInstrumentation().runOnMainSync(new Runnable() {
31             @Override
32             public void run() {
33                 Context context = getInstrumentation().getTargetContext();
34                 File libDir = LibraryLoaderHelper.getLibDir(context,
35                         LibraryLoaderHelper.PACKAGE_MANAGER_WORKAROUND_DIR);
36                 assertTrue(libDir.exists());
37                 assertTrue(libDir.isDirectory());
38                 assertEquals(libDir.list().length, 0);
39
40                 assertTrue(LibraryLoaderHelper.loadNativeLibrariesUsingWorkaroundForTesting(
41                         context));
42
43                 assertTrue(libDir.list().length > 0);
44             }
45         });
46     }
47
48     @Override
49     public void tearDown() throws Exception {
50         Context context = getInstrumentation().getTargetContext();
51         LibraryLoaderHelper.deleteLibrariesSynchronously(
52                 context, LibraryLoaderHelper.PACKAGE_MANAGER_WORKAROUND_DIR);
53         super.tearDown();
54     }
55 }