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

Side by Side Diff: components/storage_monitor/media_storage_util_unittest.cc

Issue 2028193002: Migrate WaitableEvent to enum-based constructor in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: rm comment explaining true/false Created 4 years, 6 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_FALSE(MediaStorageUtil::CanCreateFileSystem( 122 EXPECT_FALSE(MediaStorageUtil::CanCreateFileSystem(
123 "dcim:xyz", base::FilePath(FILE_PATH_LITERAL("relative")))); 123 "dcim:xyz", base::FilePath(FILE_PATH_LITERAL("relative"))));
124 EXPECT_FALSE(MediaStorageUtil::CanCreateFileSystem( 124 EXPECT_FALSE(MediaStorageUtil::CanCreateFileSystem(
125 "dcim:xyz", base::FilePath(FILE_PATH_LITERAL("../refparent")))); 125 "dcim:xyz", base::FilePath(FILE_PATH_LITERAL("../refparent"))));
126 } 126 }
127 127
128 TEST_F(MediaStorageUtilTest, DetectDeviceFiltered) { 128 TEST_F(MediaStorageUtilTest, DetectDeviceFiltered) {
129 MediaStorageUtil::DeviceIdSet devices; 129 MediaStorageUtil::DeviceIdSet devices;
130 devices.insert(kImageCaptureDeviceId); 130 devices.insert(kImageCaptureDeviceId);
131 131
132 base::WaitableEvent event(true, false); 132 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::MANUAL,
133 base::WaitableEvent::InitialState::NOT_SIGNALED);
133 base::Closure signal_event = 134 base::Closure signal_event =
134 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)); 135 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event));
135 136
136 // We need signal_event to be executed on the FILE thread, as the test thread 137 // We need signal_event to be executed on the FILE thread, as the test thread
137 // is blocked. Therefore, we invoke FilterAttachedDevices on the FILE thread. 138 // is blocked. Therefore, we invoke FilterAttachedDevices on the FILE thread.
138 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 139 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
139 base::Bind(&MediaStorageUtil::FilterAttachedDevices, 140 base::Bind(&MediaStorageUtil::FilterAttachedDevices,
140 base::Unretained(&devices), signal_event)); 141 base::Unretained(&devices), signal_event));
141 event.Wait(); 142 event.Wait();
142 EXPECT_FALSE(devices.find(kImageCaptureDeviceId) != devices.end()); 143 EXPECT_FALSE(devices.find(kImageCaptureDeviceId) != devices.end());
143 144
144 ProcessAttach(kImageCaptureDeviceId, FILE_PATH_LITERAL("/location")); 145 ProcessAttach(kImageCaptureDeviceId, FILE_PATH_LITERAL("/location"));
145 devices.insert(kImageCaptureDeviceId); 146 devices.insert(kImageCaptureDeviceId);
146 event.Reset(); 147 event.Reset();
147 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 148 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
148 base::Bind(&MediaStorageUtil::FilterAttachedDevices, 149 base::Bind(&MediaStorageUtil::FilterAttachedDevices,
149 base::Unretained(&devices), signal_event)); 150 base::Unretained(&devices), signal_event));
150 event.Wait(); 151 event.Wait();
151 152
152 EXPECT_TRUE(devices.find(kImageCaptureDeviceId) != devices.end()); 153 EXPECT_TRUE(devices.find(kImageCaptureDeviceId) != devices.end());
153 } 154 }
154 155
155 } // namespace storage_monitor 156 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698