Home | History | Annotate | Download | only in base
      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.deleteWorkaroundLibrariesSynchronously(context);
     25     }
     26 
     27     @MediumTest
     28     public void testLoadNativeLibraries() {
     29         getInstrumentation().runOnMainSync(new Runnable() {
     30             @Override
     31             public void run() {
     32                 Context context = getInstrumentation().getTargetContext();
     33                 File libDir = LibraryLoaderHelper.getWorkaroundLibDir(context);
     34                 assertTrue(libDir.exists());
     35                 assertTrue(libDir.isDirectory());
     36                 assertEquals(libDir.list().length, 0);
     37 
     38                 assertTrue(
     39                     LibraryLoaderHelper.loadNativeLibrariesUsingWorkaroundForTesting(
     40                         context));
     41 
     42                 assertTrue(libDir.list().length > 0);
     43             }
     44         });
     45     }
     46 
     47     @Override
     48     public void tearDown() throws Exception {
     49         Context context = getInstrumentation().getTargetContext();
     50         LibraryLoaderHelper.deleteWorkaroundLibrariesSynchronously(context);
     51         super.tearDown();
     52     }
     53 }
     54