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

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

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h" 5 #include "chrome/browser/extensions/api/image_writer_private/image_writer_utilit y_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/task_scheduler/post_task.h" 14 #include "base/task_scheduler/post_task.h"
15 #include "base/threading/thread_restrictions.h"
15 #include "chrome/common/extensions/removable_storage_writer.mojom.h" 16 #include "chrome/common/extensions/removable_storage_writer.mojom.h"
16 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 19
19 constexpr int64_t kTestFileSize = 1 << 15; // 32 kB 20 constexpr int64_t kTestFileSize = 1 << 15; // 32 kB
20 21
21 class ImageWriterUtilityClientTest : public InProcessBrowserTest { 22 class ImageWriterUtilityClientTest : public InProcessBrowserTest {
22 public: 23 public:
23 ImageWriterUtilityClientTest() { 24 ImageWriterUtilityClientTest() {
25 base::ThreadRestrictions::ScopedAllowIO allow_io;
24 test_device_ = base::FilePath().AppendASCII( 26 test_device_ = base::FilePath().AppendASCII(
25 extensions::mojom::RemovableStorageWriter::kTestDevice); 27 extensions::mojom::RemovableStorageWriter::kTestDevice);
26 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 28 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
27 } 29 }
28 30
29 void FillImageFileWithPattern(char pattern) { 31 void FillImageFileWithPattern(char pattern) {
32 base::ThreadRestrictions::ScopedAllowIO allow_io;
30 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &image_)); 33 EXPECT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &image_));
31 34
32 base::RunLoop run_loop; 35 base::RunLoop run_loop;
33 base::PostTaskWithTraitsAndReply( 36 base::PostTaskWithTraitsAndReply(
34 FROM_HERE, base::TaskTraits().MayBlock(), 37 FROM_HERE, base::TaskTraits().MayBlock(),
35 base::Bind(&ImageWriterUtilityClientTest::FillFile, image_, pattern), 38 base::Bind(&ImageWriterUtilityClientTest::FillFile, image_, pattern),
36 run_loop.QuitClosure()); 39 run_loop.QuitClosure());
37 40
38 run_loop.Run(); 41 run_loop.Run();
39 } 42 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 311
309 IN_PROC_BROWSER_TEST_F(ImageWriterUtilityClientTest, VerifyCancel) { 312 IN_PROC_BROWSER_TEST_F(ImageWriterUtilityClientTest, VerifyCancel) {
310 FillImageFileWithPattern('s'); 313 FillImageFileWithPattern('s');
311 FillDeviceFileWithPattern('s'); 314 FillDeviceFileWithPattern('s');
312 315
313 RunVerifyTest(CANCEL); 316 RunVerifyTest(CANCEL);
314 317
315 EXPECT_TRUE(success()); 318 EXPECT_TRUE(success());
316 EXPECT_TRUE(error().empty()); 319 EXPECT_TRUE(error().empty());
317 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698