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

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

Issue 149313003: Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes cross-compilation and test issues. 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 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"
(...skipping 13 matching lines...) Expand all
24 // Pattern to use in the image file. 24 // Pattern to use in the image file.
25 const int kImagePattern = 0x55555555; // 01010101 25 const int kImagePattern = 0x55555555; // 01010101
26 // Pattern to use in the device file. 26 // Pattern to use in the device file.
27 const int kDevicePattern = 0xAAAAAAAA; // 10101010 27 const int kDevicePattern = 0xAAAAAAAA; // 10101010
28 28
29 // A mock around the operation manager for tracking callbacks. Note that there 29 // A mock around the operation manager for tracking callbacks. Note that there
30 // are non-virtual methods on this class that should not be called in tests. 30 // are non-virtual methods on this class that should not be called in tests.
31 class MockOperationManager : public OperationManager { 31 class MockOperationManager : public OperationManager {
32 public: 32 public:
33 MockOperationManager(); 33 MockOperationManager();
34 explicit MockOperationManager(Profile* profile);
34 virtual ~MockOperationManager(); 35 virtual ~MockOperationManager();
35 36
36 MOCK_METHOD3(OnProgress, void(const ExtensionId& extension_id, 37 MOCK_METHOD3(OnProgress, void(const ExtensionId& extension_id,
37 image_writer_api::Stage stage, 38 image_writer_api::Stage stage,
38 int progress)); 39 int progress));
39 // Callback for completion events. 40 // Callback for completion events.
40 MOCK_METHOD1(OnComplete, void(const std::string& extension_id)); 41 MOCK_METHOD1(OnComplete, void(const std::string& extension_id));
41 42
42 // Callback for error events. 43 // Callback for error events.
43 MOCK_METHOD4(OnError, void(const ExtensionId& extension_id, 44 MOCK_METHOD4(OnError, void(const ExtensionId& extension_id,
44 image_writer_api::Stage stage, 45 image_writer_api::Stage stage,
45 int progress, 46 int progress,
46 const std::string& error_message)); 47 const std::string& error_message));
47 }; 48 };
48 49
49 // Base class for unit tests that manages creating image and device files. 50 // Base class for unit tests that manages creating image and device files.
50 class ImageWriterUnitTestBase : public testing::Test { 51 class ImageWriterUnitTestBase : public testing::Test {
51 public: 52 public:
52 ImageWriterUnitTestBase(); 53 ImageWriterUnitTestBase();
53 virtual ~ImageWriterUnitTestBase(); 54 virtual ~ImageWriterUnitTestBase();
54 55
55 protected: 56 protected:
56 virtual void SetUp() OVERRIDE; 57 virtual void SetUp() OVERRIDE;
57 58
58 virtual void TearDown() OVERRIDE; 59 virtual void TearDown() OVERRIDE;
59 60
60 // Compare the image and device files, returning true if they are the same, 61 // Fills |file| with |length| bytes of |pattern|, overwriting any existing
61 // false if different. 62 // data.
62 bool CompareImageAndDevice(); 63 bool FillFile(const base::FilePath& file,
64 const int pattern,
65 const int length);
63 66
64 base::ScopedTempDir temp_dir_; 67 base::ScopedTempDir temp_dir_;
65 base::FilePath test_image_path_; 68 base::FilePath test_image_path_;
66 base::FilePath test_device_path_; 69 base::FilePath test_device_path_;
67 70
68 private: 71 private:
69 // Fills |file| with |length| bytes of |pattern|, overwriting any existing
70 // data.
71 bool FillFile(const base::FilePath& file,
72 const int pattern,
73 const int length);
74
75 content::TestBrowserThreadBundle thread_bundle_; 72 content::TestBrowserThreadBundle thread_bundle_;
76 }; 73 };
77 74
78 } // namespace image_writer 75 } // namespace image_writer
79 } // namespace extensions 76 } // namespace extensions
80 77
81 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_ 78 #endif // CHROME_BROWSER_EXTENSIONS_API_IMAGE_WRITER_PRIVATE_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698