]> git.saurik.com Git - android/aapt.git/blame - tests/MockFileFinder.h
am 6080cc5f: resolved conflicts for merge of dd52dfed to jb-mr1.1-ub-dev
[android/aapt.git] / tests / MockFileFinder.h
CommitLineData
dddb1fc7
JG
1//
2// Copyright 2011 The Android Open Source Project
3//
4
5#ifndef MOCKFILEFINDER_H
6#define MOCKFILEFINDER_H
7
8#include <utils/Vector.h>
9#include <utils/KeyedVector.h>
10#include <utils/String8.h>
11
12#include "DirectoryWalker.h"
13
14using namespace android;
15
16class MockFileFinder : public FileFinder {
17public:
18 MockFileFinder (KeyedVector<String8, KeyedVector<String8,time_t> >& files)
19 : mFiles(files)
20 {
21 // Nothing left to do
22 };
23
24 /**
25 * findFiles implementation for the abstraction.
26 * PRECONDITIONS:
27 * No checking is done, so there MUST be an entry in mFiles with
28 * path matching basePath.
29 *
30 * POSTCONDITIONS:
31 * fileStore is filled with a copy of the data in mFiles corresponding
32 * to the basePath.
33 */
34
35 virtual bool findFiles(String8 basePath, Vector<String8>& extensions,
36 KeyedVector<String8,time_t>& fileStore,
37 DirectoryWalker* dw)
38 {
39 const KeyedVector<String8,time_t>* payload(&mFiles.valueFor(basePath));
40 // Since KeyedVector doesn't implement swap
41 // (who doesn't use swap??) we loop and add one at a time.
42 for (size_t i = 0; i < payload->size(); ++i) {
43 fileStore.add(payload->keyAt(i),payload->valueAt(i));
44 }
45 return true;
46 }
47
48private:
49 // Virtual mapping between "directories" and the "files" contained
50 // in them
51 KeyedVector<String8, KeyedVector<String8,time_t> > mFiles;
52};
53
54
55#endif // MOCKFILEFINDER_H