Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / extensions / test_extension_dir.h
blobdf1d73192d6ceba0494c44c83df4894bc2d6c1b1
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_DIR_H_
6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_DIR_H_
8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h"
10 #include "base/strings/string_piece.h"
12 namespace extensions {
14 // Provides a temporary directory to build an extension into. This lets all of
15 // an extension's code live inside the test instead of in a separate directory.
16 class TestExtensionDir {
17 public:
18 TestExtensionDir();
20 ~TestExtensionDir();
22 // Writes |manifest| to manifest.json within the unpacked dir. No validation
23 // is performed. If desired this should be done on extension installation.
24 void WriteManifest(base::StringPiece manifest);
26 // Writes |contents| to |filename| within the unpacked dir, overwriting
27 // anything that was already there.
28 void WriteFile(const base::FilePath::StringType& filename,
29 base::StringPiece contents);
31 // Packs the extension into a .crx, and returns the path to that
32 // .crx. Multiple calls to Pack() will produce extensions with the same ID.
33 base::FilePath Pack();
35 // Returns the path to the unpacked directory.
36 base::FilePath unpacked_path() {
37 return dir_.path();
40 private:
41 // Stores files that make up the extension.
42 base::ScopedTempDir dir_;
44 // Stores the generated .crx and .pem.
45 base::ScopedTempDir crx_dir_;
48 } // namespace extensions
50 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_DIR_H_