diff options
author | Josiah Gaskin <josiahgaskin@google.com> | 2011-06-06 17:00:35 -0700 |
---|---|---|
committer | Josiah Gaskin <josiahgaskin@google.com> | 2011-07-20 15:20:26 -0700 |
commit | 8a39da80b33691b0c82458c3b7727e13ff71277e (patch) | |
tree | b6fa94370ecb2dba85d5fdb45c83729cef8708e1 /tools/aapt/tests/MockFileFinder.h | |
parent | 1e24ccbdd56a45c8bb5f2eba94af5aecd2d02554 (diff) | |
download | frameworks_base-8a39da80b33691b0c82458c3b7727e13ff71277e.zip frameworks_base-8a39da80b33691b0c82458c3b7727e13ff71277e.tar.gz frameworks_base-8a39da80b33691b0c82458c3b7727e13ff71277e.tar.bz2 |
Added Caching for PreProcessed PNGs
Added a cache management system for pre-processed PNG files
along with unit tests. The cache system will be used if
the --no-crunch flag is passed to AAPT during the package
phase. The cache can be updated by a call to 'aapt crunch'
(see usage statement). Also put in benchmarking code.
Change-Id: I58271fb2ee2f5f9075fd74d4ff6f15e7afabd05c
Diffstat (limited to 'tools/aapt/tests/MockFileFinder.h')
-rw-r--r-- | tools/aapt/tests/MockFileFinder.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/aapt/tests/MockFileFinder.h b/tools/aapt/tests/MockFileFinder.h new file mode 100644 index 0000000..da5ea4f --- /dev/null +++ b/tools/aapt/tests/MockFileFinder.h @@ -0,0 +1,55 @@ +// +// Copyright 2011 The Android Open Source Project +// + +#ifndef MOCKFILEFINDER_H +#define MOCKFILEFINDER_H + +#include <utils/Vector.h> +#include <utils/KeyedVector.h> +#include <utils/String8.h> + +#include "DirectoryWalker.h" + +using namespace android; + +class MockFileFinder : public FileFinder { +public: + MockFileFinder (KeyedVector<String8, KeyedVector<String8,time_t> >& files) + : mFiles(files) + { + // Nothing left to do + }; + + /** + * findFiles implementation for the abstraction. + * PRECONDITIONS: + * No checking is done, so there MUST be an entry in mFiles with + * path matching basePath. + * + * POSTCONDITIONS: + * fileStore is filled with a copy of the data in mFiles corresponding + * to the basePath. + */ + + virtual bool findFiles(String8 basePath, Vector<String8>& extensions, + KeyedVector<String8,time_t>& fileStore, + DirectoryWalker* dw) + { + const KeyedVector<String8,time_t>* payload(&mFiles.valueFor(basePath)); + // Since KeyedVector doesn't implement swap + // (who doesn't use swap??) we loop and add one at a time. + for (size_t i = 0; i < payload->size(); ++i) { + fileStore.add(payload->keyAt(i),payload->valueAt(i)); + } + return true; + } + +private: + // Virtual mapping between "directories" and the "files" contained + // in them + KeyedVector<String8, KeyedVector<String8,time_t> > mFiles; +}; + + +#endif // MOCKFILEFINDER_H
\ No newline at end of file |