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

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

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and now working on Windows with minimal changes. 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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 10 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ImageWriterUnitTestBase::TearDown(); 82 ImageWriterUnitTestBase::TearDown();
83 } 83 }
84 84
85 base::ScopedTempDir temp_dir_; 85 base::ScopedTempDir temp_dir_;
86 base::FilePath image_file_; 86 base::FilePath image_file_;
87 base::FilePath zip_file_; 87 base::FilePath zip_file_;
88 }; 88 };
89 89
90 } // namespace 90 } // namespace
91 91
92 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 92 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_WIN)
93 // Tests a successful unzip. 93 // Tests a successful unzip.
94 TEST_F(ImageWriterOperationTest, Unzip) { 94 TEST_F(ImageWriterOperationTest, Unzip) {
95 MockOperationManager manager; 95 base::RunLoop loop;
96 QuittingMockManager manager(loop.QuitClosure());
96 97
97 scoped_refptr<OperationForTest> operation( 98 scoped_refptr<OperationForTest> operation(
98 new OperationForTest(manager.AsWeakPtr(), 99 new OperationForTest(manager.AsWeakPtr(),
99 kDummyExtensionId, 100 kDummyExtensionId,
100 test_device_path_.AsUTF8Unsafe())); 101 test_device_path_.AsUTF8Unsafe()));
101 102
102 scoped_ptr<base::FilePath> zip_file(new base::FilePath(zip_file_)); 103 scoped_ptr<base::FilePath> zip_file(new base::FilePath(zip_file_));
103 104
104 // At least one progress report > 0% and < 100%. 105 // At least one progress report > 0% and < 100%.
105 EXPECT_CALL(manager, OnProgress(kDummyExtensionId, 106 EXPECT_CALL(manager, OnProgress(kDummyExtensionId,
(...skipping 15 matching lines...) Expand all
121 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1); 122 EXPECT_CALL(manager, OnComplete(kDummyExtensionId)).Times(1);
122 // No errors 123 // No errors
123 EXPECT_CALL(manager, OnError(_, _, _, _)).Times(0); 124 EXPECT_CALL(manager, OnError(_, _, _, _)).Times(0);
124 125
125 content::BrowserThread::PostTask(content::BrowserThread::FILE, 126 content::BrowserThread::PostTask(content::BrowserThread::FILE,
126 FROM_HERE, 127 FROM_HERE,
127 base::Bind(&OperationForTest::UnzipStart, 128 base::Bind(&OperationForTest::UnzipStart,
128 operation, 129 operation,
129 base::Passed(&zip_file))); 130 base::Passed(&zip_file)));
130 131
131 base::RunLoop().RunUntilIdle(); 132 loop.Run();
132 133
133 EXPECT_TRUE(base::ContentsEqual(image_file_, test_device_path_)); 134 EXPECT_TRUE(ImageWrittenToDevice(image_file_, test_device_path_));
134 } 135 }
135 #endif 136 #endif
136 137
137 TEST_F(ImageWriterOperationTest, Creation) { 138 TEST_F(ImageWriterOperationTest, Creation) {
138 MockOperationManager manager; 139 MockOperationManager manager;
139 scoped_refptr<Operation> op( 140 scoped_refptr<Operation> op(
140 new OperationForTest(manager.AsWeakPtr(), 141 new OperationForTest(manager.AsWeakPtr(),
141 kDummyExtensionId, 142 kDummyExtensionId,
142 test_device_path_.AsUTF8Unsafe())); 143 test_device_path_.AsUTF8Unsafe()));
143 144
144 EXPECT_EQ(0, op->GetProgress()); 145 EXPECT_EQ(0, op->GetProgress());
145 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, op->GetStage()); 146 EXPECT_EQ(image_writer_api::STAGE_UNKNOWN, op->GetStage());
146 } 147 }
147 148
148 } // namespace image_writer 149 } // namespace image_writer
149 } // namespace extensions 150 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698