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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/test_utils.h

Issue 282853003: Unmounts volumes before writing to a drive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds compile guard to Chrome OS includes in test_utils.h Created 6 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h" 12 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h"
13 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 13 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
14 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 #if defined(OS_CHROMEOS)
20 #include "chromeos/disks/disk_mount_manager.h"
21 #include "chromeos/disks/mock_disk_mount_manager.h"
22 #endif
23
19 namespace extensions { 24 namespace extensions {
20 namespace image_writer { 25 namespace image_writer {
21 26
22 const char kDummyExtensionId[] = "DummyExtension"; 27 const char kDummyExtensionId[] = "DummyExtension";
23 28
24 // Default file size to use in tests. Currently 32kB. 29 // Default file size to use in tests. Currently 32kB.
25 const int kTestFileSize = 32 * 1024; 30 const int kTestFileSize = 32 * 1024;
26 // Pattern to use in the image file. 31 // Pattern to use in the image file.
27 const int kImagePattern = 0x55555555; // 01010101 32 const int kImagePattern = 0x55555555; // 01010101
28 // Pattern to use in the device file. 33 // Pattern to use in the device file.
(...skipping 13 matching lines...) Expand all
42 // Callback for completion events. 47 // Callback for completion events.
43 MOCK_METHOD1(OnComplete, void(const std::string& extension_id)); 48 MOCK_METHOD1(OnComplete, void(const std::string& extension_id));
44 49
45 // Callback for error events. 50 // Callback for error events.
46 MOCK_METHOD4(OnError, void(const ExtensionId& extension_id, 51 MOCK_METHOD4(OnError, void(const ExtensionId& extension_id,
47 image_writer_api::Stage stage, 52 image_writer_api::Stage stage,
48 int progress, 53 int progress,
49 const std::string& error_message)); 54 const std::string& error_message));
50 }; 55 };
51 56
57 #if defined(OS_CHROMEOS)
58 // A fake for the DiskMountManager that will successfully call the unmount
59 // callback.
60 class FakeDiskMountManager : public chromeos::disks::MockDiskMountManager {
61 public:
62 FakeDiskMountManager();
63 virtual ~FakeDiskMountManager();
64
65 virtual void UnmountDeviceRecursively(
66 const std::string& device_path,
67 const UnmountDeviceRecursivelyCallbackType& callback) OVERRIDE;
68 /*
69 MOCK_METHOD1(AddObserver, void(chromeos::disks::DiskMountManager::Observer*));
70 MOCK_METHOD1(RemoveObserver,
71 void(chromeos::disks::DiskMountManager::Observer*));
72 MOCK_CONST_METHOD0(disks, const DiskMap&());
73 MOCK_CONST_METHOD1(FindDiskBySourcePath, const Disk*(const std::string&));
74 MOCK_CONST_METHOD0(mount_points, const MountPointMap&());
75 MOCK_METHOD0(RequestMountInfoRefresh, void());
76 MOCK_METHOD4(MountPath, void(const std::string&, const std::string&, const
77 std::string&, chromeos::MountType));
78 MOCK_METHOD3(UnmountPath, void(const std::string&, chromeos::UnmountOptions,
79 const UnmountPathCallback&));
80 MOCK_METHOD1(FormatMountedDevice, void(const std::string&));
81 */
82
83 private:
84 DiskMap disks_;
85 };
86 #endif
87
52 class FakeImageWriterClient : public ImageWriterUtilityClient { 88 class FakeImageWriterClient : public ImageWriterUtilityClient {
53 public: 89 public:
54 FakeImageWriterClient(); 90 FakeImageWriterClient();
55 91
56 virtual void Write(const ProgressCallback& progress_callback, 92 virtual void Write(const ProgressCallback& progress_callback,
57 const SuccessCallback& success_callback, 93 const SuccessCallback& success_callback,
58 const ErrorCallback& error_callback, 94 const ErrorCallback& error_callback,
59 const base::FilePath& source, 95 const base::FilePath& source,
60 const base::FilePath& target) OVERRIDE; 96 const base::FilePath& target) OVERRIDE;
61 97
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 base::FilePath test_device_path_; 147 base::FilePath test_device_path_;
112 148
113 private: 149 private:
114 content::TestBrowserThreadBundle thread_bundle_; 150 content::TestBrowserThreadBundle thread_bundle_;
115 }; 151 };
116 152
117 } // namespace image_writer 153 } // namespace image_writer
118 } // namespace extensions 154 } // namespace extensions
119 155
120 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_ 156 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698