コード例 #1
0
  public void testSDCard() throws InterruptedException {
    final FSGraph graph =
        new FSGraphFactory().createGraph(Environment.getExternalStorageDirectory().getParentFile());
    assertNotNull("createGraph is null", graph);

    final Set<String> set = new HashSet<>();
    set.add("Android");
    set.add("data");
    set.add("sdcard0");

    int totalCount = 0;
    final FSGraphBFIterator bfs =
        new FSGraphBFIterator(
            graph, new IndexItem(Environment.getExternalStorageDirectory().getParentFile()));
    while (bfs.hasNext()) {
      final IndexItem item = bfs.next();
      set.remove(item.name);
      totalCount++;
    }
    assertEquals("found not all files", 0, set.size());
  }
コード例 #2
0
  public void testSearch() throws InterruptedException {
    final FSGraph graph = new FSGraphFactory().createGraph(new File(mRootDir));
    assertNotNull("createGraph is null", graph);

    final Set<String> set = new HashSet<>();
    set.add("dir1");
    set.add("file1.1");
    set.add("file311.2");
    set.add("file001.3");
    set.add("f12fsdf3"); // nonexistent.

    int totalCount = 0;
    final FSGraphBFIterator bfs = new FSGraphBFIterator(graph, new IndexItem(new File(mRootDir)));
    while (bfs.hasNext()) {
      final IndexItem item = bfs.next();
      set.remove(item.name);
      totalCount++;
    }
    assertEquals("walk count unexpected", getDirsCount() + getFilesCount(), totalCount);
    assertEquals("found not all files", 1, set.size());
  }