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

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

Issue 2851593002: Use ScopedTaskEnvironment instead of MessageLoopForUI in chrome tests. (Closed)
Patch Set: self-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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/message_loop/message_loop.h" 5 #include "base/test/scoped_task_environment.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 7 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
8 #include "chrome/browser/extensions/api/image_writer_private/operation.h" 8 #include "chrome/browser/extensions/api/image_writer_private/operation.h"
9 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p rovider.h" 9 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p rovider.h"
10 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h" 10 #include "chrome/browser/extensions/api/image_writer_private/test_utils.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/common/extensions/api/image_writer_private.h" 12 #include "chrome/common/extensions/api/image_writer_private.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 using api::image_writer_private::RemovableStorageDevice; 17 using api::image_writer_private::RemovableStorageDevice;
18 using extensions::image_writer::FakeImageWriterClient; 18 using extensions::image_writer::FakeImageWriterClient;
19 19
20 class ImageWriterPrivateApiTest : public ExtensionApiTest { 20 class ImageWriterPrivateApiTest : public ExtensionApiTest {
21 public: 21 public:
22 ImageWriterPrivateApiTest()
23 : scoped_task_environment_(
24 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
25
22 void SetUpInProcessBrowserTestFixture() override { 26 void SetUpInProcessBrowserTestFixture() override {
23 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 27 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
24 test_utils_.SetUp(true); 28 test_utils_.SetUp(true);
25 29
26 ASSERT_TRUE(test_utils_.FillFile(test_utils_.GetImagePath(), 30 ASSERT_TRUE(test_utils_.FillFile(test_utils_.GetImagePath(),
27 image_writer::kImagePattern, 31 image_writer::kImagePattern,
28 image_writer::kTestFileSize)); 32 image_writer::kTestFileSize));
29 ASSERT_TRUE(test_utils_.FillFile(test_utils_.GetDevicePath(), 33 ASSERT_TRUE(test_utils_.FillFile(test_utils_.GetDevicePath(),
30 image_writer::kDevicePattern, 34 image_writer::kDevicePattern,
31 image_writer::kTestFileSize)); 35 image_writer::kTestFileSize));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 base::BindOnce(&FakeImageWriterClient::Progress, 86 base::BindOnce(&FakeImageWriterClient::Progress,
83 test_utils_.GetUtilityClient(), 100)); 87 test_utils_.GetUtilityClient(), 100));
84 content::BrowserThread::PostTask( 88 content::BrowserThread::PostTask(
85 content::BrowserThread::FILE, FROM_HERE, 89 content::BrowserThread::FILE, FROM_HERE,
86 base::BindOnce(&FakeImageWriterClient::Success, 90 base::BindOnce(&FakeImageWriterClient::Success,
87 test_utils_.GetUtilityClient())); 91 test_utils_.GetUtilityClient()));
88 } 92 }
89 #endif 93 #endif
90 94
91 protected: 95 protected:
92 base::MessageLoopForUI message_loop_; 96 base::test::ScopedTaskEnvironment scoped_task_environment_;
93 image_writer::ImageWriterTestUtils test_utils_; 97 image_writer::ImageWriterTestUtils test_utils_;
94 }; 98 };
95 99
96 IN_PROC_BROWSER_TEST_F(ImageWriterPrivateApiTest, TestListDevices) { 100 IN_PROC_BROWSER_TEST_F(ImageWriterPrivateApiTest, TestListDevices) {
97 ASSERT_TRUE(RunExtensionTest("image_writer_private/list_devices")) 101 ASSERT_TRUE(RunExtensionTest("image_writer_private/list_devices"))
98 << message_; 102 << message_;
99 } 103 }
100 104
101 IN_PROC_BROWSER_TEST_F(ImageWriterPrivateApiTest, TestWriteFromFile) { 105 IN_PROC_BROWSER_TEST_F(ImageWriterPrivateApiTest, TestWriteFromFile) {
102 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( 106 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest(
(...skipping 10 matching lines...) Expand all
113 test_utils_.GetUtilityClient()->SetVerifyCallback(base::Bind( 117 test_utils_.GetUtilityClient()->SetVerifyCallback(base::Bind(
114 &ImageWriterPrivateApiTest::ImageWriterUtilityClientCall, 118 &ImageWriterPrivateApiTest::ImageWriterUtilityClientCall,
115 base::Unretained(this))); 119 base::Unretained(this)));
116 #endif 120 #endif
117 121
118 ASSERT_TRUE(RunPlatformAppTest("image_writer_private/write_from_file")) 122 ASSERT_TRUE(RunPlatformAppTest("image_writer_private/write_from_file"))
119 << message_; 123 << message_;
120 } 124 }
121 125
122 } // namespace extensions 126 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698