Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: chrome/browser/extensions/api/image_writer_private/test_utils.h

Issue 109793006: Adds ImageWriterPrivate.destroyPartitions operation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/image_writer_private/test_utils.h
diff --git a/chrome/browser/extensions/api/image_writer_private/test_utils.h b/chrome/browser/extensions/api/image_writer_private/test_utils.h
index 88ccf492b4e8f9caf48428bce2dbfeda219e64eb..78f3e2606da785f01686c0fce4961c21e6d55de2 100644
--- a/chrome/browser/extensions/api/image_writer_private/test_utils.h
+++ b/chrome/browser/extensions/api/image_writer_private/test_utils.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
#include "base/file_util.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "chrome/browser/extensions/api/image_writer_private/operation_manager.h"
@@ -17,8 +18,16 @@ namespace extensions {
namespace image_writer {
const char kDummyExtensionId[] = "DummyExtension";
-const char kTestData[] = "This is some test data, padded. ";
+// Default file size to use in tests. Currently 1MB.
+const int kTestFileSize = 1024 * 1024;
tbarzic 2013/12/14 01:01:04 can't you use a bit smaller numbers :) I'm not sur
Drew Haven 2013/12/16 20:15:33 I want to make sure we get a few cycles through.
tbarzic 2013/12/16 20:33:45 Another option would be to set different values in
Drew Haven 2013/12/16 22:05:25 That's a good idea. I figured it was more depende
+// Pattern to use in the image file.
+const char kImagePattern = 0x55; // 01010101
+// Pattern to use in the device file.
+const char kDevicePattern = 0xAA; // 10101010
+
+// A mock around the operation manager for tracking callbacks. Note that there
+// are non-virtual methods on this class that should not be called in tests.
class MockOperationManager : public OperationManager {
public:
MockOperationManager();
@@ -37,15 +46,28 @@ class MockOperationManager : public OperationManager {
const std::string& error_message));
};
+// Base class for unit tests that manages creating image and device files.
class ImageWriterUnitTestBase : public testing::Test {
- public:
+ protected:
virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
- base::FilePath test_image_;
- base::FilePath test_device_;
+ // Compare the image and device files, returning true if they are the same,
+ // false if different.
+ bool CompareImageAndDevice();
+
+ base::ScopedTempDir temp_dir_;
+ base::FilePath test_image_path_;
+ base::FilePath test_device_path_;
+
private:
+ // Fills |file| with |length| bytes of |pattern|, overwriting any existing
+ // data.
+ bool FillFile(const base::FilePath& file,
+ const char pattern,
+ const int length);
+
content::TestBrowserThreadBundle thread_bundle_;
};

Powered by Google App Engine
This is Rietveld 408576698