Index: chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc |
diff --git a/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc b/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1e14dde1bf371c672f47c6fe801bf19afb51bcbd |
--- /dev/null |
+++ b/chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc |
@@ -0,0 +1,57 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/run_loop.h" |
+#include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation.h" |
+#include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
+#include "chrome/browser/extensions/api/image_writer_private/test_utils.h" |
+ |
+namespace extensions { |
+namespace image_writer { |
+ |
+using testing::_; |
+using testing::Lt; |
+using testing::AnyNumber; |
+using testing::AtLeast; |
+ |
+namespace { |
+ |
+class ImageWriterDestroyPartitionsOperationTest |
+ : public ImageWriterUnitTestBase { |
+}; |
+ |
+} // namespace |
tbarzic
2013/12/14 01:01:04
If possible the whole test file should go in an an
Drew Haven
2013/12/16 20:15:33
Done.
|
+ |
+// Tests that the DestroyPartitionsOperation can successfully zero the first |
+// kPartitionTableSize bytes of an image. |
+TEST_F(ImageWriterDestroyPartitionsOperationTest, DestroyPartitions) { |
+ MockOperationManager manager; |
+ base::RunLoop loop; |
+ |
+ scoped_refptr<DestroyPartitionsOperation> operation |
+ = new DestroyPartitionsOperation(manager.AsWeakPtr(), |
tbarzic
2013/12/14 01:01:04
scoped_refptr<...>operation(
new ....)
Drew Haven
2013/12/16 20:15:33
Done.
|
+ kDummyExtensionId, |
+ test_device_path_.AsUTF8Unsafe()); |
+ |
+ EXPECT_CALL(manager, OnProgress(kDummyExtensionId, _, _)).Times(0); |
+ EXPECT_CALL(manager, OnProgress(kDummyExtensionId, |
+ image_writer_api::STAGE_WRITE, |
+ _)).Times(AnyNumber()); |
+ EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); |
+ EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); |
+ |
+ operation->Start(); |
+ |
+ loop.RunUntilIdle(); |
+ |
+ char image_data[kPartitionTableSize]; |
+ char zeroes[kPartitionTableSize]; |
+ memset(zeroes, 0, kPartitionTableSize); |
+ ASSERT_EQ(kPartitionTableSize, |
+ base::ReadFile(test_device_path_, image_data, kPartitionTableSize)); |
+ EXPECT_EQ(0, memcmp(image_data, zeroes, kPartitionTableSize)); |
+} |
+ |
+} // namespace image_writer |
+} // namespace extensions |