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

Unified Diff: chrome/browser/extensions/api/image_writer_private/test_utils.h

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/image_writer_private/test_utils.h
diff --git a/chrome/browser/extensions/api/image_writer_private/test_utils.h b/chrome/browser/extensions/api/image_writer_private/test_utils.h
index b290e881ee87e86dd7096e3d1bfb981b5d9c5517..9ace59a93e78138a7f6de87be6f5c53437c6285b 100644
--- a/chrome/browser/extensions/api/image_writer_private/test_utils.h
+++ b/chrome/browser/extensions/api/image_writer_private/test_utils.h
@@ -11,6 +11,7 @@
#include "base/run_loop.h"
#include "chrome/browser/extensions/api/image_writer_private/operation_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -46,6 +47,24 @@ class MockOperationManager : public OperationManager {
const std::string& error_message));
};
+// A specialized MockOperationManager that will call a quit closure when the
+// operation completes or errors. This is useful because when using other
+// processes the message queue may empty and so we need to wait for a response
+// instead of running until idle.
+class QuittingMockManager : public MockOperationManager {
+ public:
+ explicit QuittingMockManager(const base::Closure& quit_closure);
+
+ virtual void OnComplete(const ExtensionId& extension_id);
+ virtual void OnError(const ExtensionId& extension_id,
+ image_writer_api::Stage stage,
+ int progress,
+ const std::string& error_message);
+
+ private:
+ base::Closure quit_closure_;
+};
+
// Base class for unit tests that manages creating image and device files.
class ImageWriterUnitTestBase : public testing::Test {
public:
@@ -57,9 +76,11 @@ class ImageWriterUnitTestBase : public testing::Test {
virtual void TearDown() OVERRIDE;
- // Compare the image and device files, returning true if they are the same,
- // false if different.
- bool CompareImageAndDevice();
+ // Verifies that the data in image_path was written to the file at
+ // device_path. This is different from base::ContentsEqual because the device
+ // may be larger than the image.
+ bool ImageWrittenToDevice(const base::FilePath& image_path,
+ const base::FilePath& device_path);
base::ScopedTempDir temp_dir_;
base::FilePath test_image_path_;
@@ -73,6 +94,7 @@ class ImageWriterUnitTestBase : public testing::Test {
const int length);
content::TestBrowserThreadBundle thread_bundle_;
+ content::InProcessUtilityThreadHelper utility_thread_helper_;
};
} // namespace image_writer

Powered by Google App Engine
This is Rietveld 408576698