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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation_unittest.cc

Issue 382053004: Adds API test for imageWriterPrivate.writeFromFile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes memory leak. Created 6 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.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" 7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
8 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" 8 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 namespace image_writer { 12 namespace image_writer {
13 namespace { 13 namespace {
14 14
15 using testing::_; 15 using testing::_;
16 using testing::AnyNumber; 16 using testing::AnyNumber;
17 using testing::AtLeast; 17 using testing::AtLeast;
18 18
19 class ImageWriterDestroyPartitionsOperationTest 19 class ImageWriterDestroyPartitionsOperationTest
20 : public ImageWriterUnitTestBase {}; 20 : public ImageWriterUnitTestBase {};
21 21
22 TEST_F(ImageWriterDestroyPartitionsOperationTest, EndToEnd) { 22 TEST_F(ImageWriterDestroyPartitionsOperationTest, EndToEnd) {
23 TestingProfile profile; 23 TestingProfile profile;
24 MockOperationManager manager(&profile); 24 MockOperationManager manager(&profile);
25 scoped_refptr<FakeImageWriterClient> client = FakeImageWriterClient::Create();
26 25
27 scoped_refptr<DestroyPartitionsOperation> operation( 26 scoped_refptr<DestroyPartitionsOperation> operation(
28 new DestroyPartitionsOperation(manager.AsWeakPtr(), 27 new DestroyPartitionsOperation(
29 kDummyExtensionId, 28 manager.AsWeakPtr(),
30 test_device_path_.AsUTF8Unsafe())); 29 kDummyExtensionId,
31 30 test_utils_.GetDevicePath().AsUTF8Unsafe()));
32 #if !defined(OS_CHROMEOS)
33 operation->SetUtilityClientForTesting(client);
34 #endif
35 31
36 EXPECT_CALL( 32 EXPECT_CALL(
37 manager, 33 manager,
38 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _)) 34 OnProgress(kDummyExtensionId, image_writer_api::STAGE_VERIFYWRITE, _))
39 .Times(AnyNumber()); 35 .Times(AnyNumber());
40 EXPECT_CALL(manager, OnProgress(kDummyExtensionId, 36 EXPECT_CALL(manager, OnProgress(kDummyExtensionId,
41 image_writer_api::STAGE_WRITE, 37 image_writer_api::STAGE_WRITE,
42 _)).Times(AnyNumber()); 38 _)).Times(AnyNumber());
43 EXPECT_CALL(manager, 39 EXPECT_CALL(manager,
44 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 0)) 40 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 0))
45 .Times(AtLeast(1)); 41 .Times(AtLeast(1));
46 EXPECT_CALL(manager, 42 EXPECT_CALL(manager,
47 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 100)) 43 OnProgress(kDummyExtensionId, image_writer_api::STAGE_WRITE, 100))
48 .Times(AtLeast(1)); 44 .Times(AtLeast(1));
49 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); 45 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1);
50 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0); 46 EXPECT_CALL(manager, OnError(kDummyExtensionId, _, _, _)).Times(0);
51 47
52 operation->Start(); 48 operation->Start();
53 49
54 base::RunLoop().RunUntilIdle(); 50 base::RunLoop().RunUntilIdle();
55 51
56 #if !defined(OS_CHROMEOS) 52 #if !defined(OS_CHROMEOS)
57 client->Progress(0); 53 test_utils_.GetUtilityClient()->Progress(0);
58 client->Progress(50); 54 test_utils_.GetUtilityClient()->Progress(50);
59 client->Progress(100); 55 test_utils_.GetUtilityClient()->Progress(100);
60 client->Success(); 56 test_utils_.GetUtilityClient()->Success();
61 57
62 base::RunLoop().RunUntilIdle(); 58 base::RunLoop().RunUntilIdle();
63 #endif 59 #endif
64 } 60 }
65 61
66 } // namespace 62 } // namespace
67 } // namespace image_writer 63 } // namespace image_writer
68 } // namespace extensions 64 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/image_writer_private/image_writer_private_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698