OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "base/run_loop.h" | |
6 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h" | |
7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | |
8 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" | |
9 | |
10 namespace extensions { | |
11 namespace image_writer { | |
12 | |
13 using testing::_; | |
14 using testing::Lt; | |
15 using testing::AnyNumber; | |
16 using testing::AtLeast; | |
17 | |
18 namespace { | |
19 | |
20 class ImageWriterDestroyPartitionsOperationTest | |
21 : public ImageWriterUnitTestBase { | |
22 }; | |
23 | |
24 } // 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.
| |
25 | |
26 // Tests that the DestroyPartitionsOperation can successfully zero the first | |
27 // kPartitionTableSize bytes of an image. | |
28 TEST_F(ImageWriterDestroyPartitionsOperationTest, DestroyPartitions) { | |
29 MockOperationManager manager; | |
30 base::RunLoop loop; | |
31 | |
32 scoped_refptr<DestroyPartitionsOperation> operation | |
33 = new DestroyPartitionsOperation(manager.AsWeakPtr(), | |
tbarzic
2013/12/14 01:01:04
scoped_refptr<...>operation(
new ....)
Drew Haven
2013/12/16 20:15:33
Done.
| |
34 kDummyExtensionId, | |
35 test_device_path_.AsUTF8Unsafe()); | |
36 | |
37 EXPECT_CALL(manager, OnProgress(kDummyExtensionId, _, _)).Times(0); | |
38 EXPECT_CALL(manager, OnProgress(kDummyExtensionId, | |
39 image_writer_api::STAGE_WRITE, | |
40 _)).Times(AnyNumber()); | |
41 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); | |
42 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); | |
43 | |
44 operation->Start(); | |
45 | |
46 loop.RunUntilIdle(); | |
47 | |
48 char image_data[kPartitionTableSize]; | |
49 char zeroes[kPartitionTableSize]; | |
50 memset(zeroes, 0, kPartitionTableSize); | |
51 ASSERT_EQ(kPartitionTableSize, | |
52 base::ReadFile(test_device_path_, image_data, kPartitionTableSize)); | |
53 EXPECT_EQ(0, memcmp(image_data, zeroes, kPartitionTableSize)); | |
54 } | |
55 | |
56 } // namespace image_writer | |
57 } // namespace extensions | |
OLD | NEW |