1 // Copyright 2014 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 #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 #include "chrome/test/base/testing_profile.h"
11 namespace extensions {
12 namespace image_writer {
16 using testing::AnyNumber;
17 using testing::AtLeast;
19 class ImageWriterDestroyPartitionsOperationTest
20 : public ImageWriterUnitTestBase {};
22 TEST_F(ImageWriterDestroyPartitionsOperationTest, EndToEnd) {
23 TestingProfile profile;
24 MockOperationManager manager(&profile);
26 scoped_refptr<DestroyPartitionsOperation> operation(
27 new DestroyPartitionsOperation(
30 test_utils_.GetDevicePath().AsUTF8Unsafe()));
34 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _))
36 EXPECT_CALL(manager, OnProgress(kDummyExtensionId,
37 image_writer_api::STAGE_WRITE,
38 _)).Times(AnyNumber());
40 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 0))
43 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 100))
45 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1);
46 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0);
50 base::RunLoop().RunUntilIdle();
52 #if !defined(OS_CHROMEOS)
53 test_utils_.GetUtilityClient()->Progress(0);
54 test_utils_.GetUtilityClient()->Progress(50);
55 test_utils_.GetUtilityClient()->Progress(100);
56 test_utils_.GetUtilityClient()->Success();
58 base::RunLoop().RunUntilIdle();
63 } // namespace image_writer
64 } // namespace extensions