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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager_unittest.cc

Issue 1878083002: Implement IsAsciiUpper and IsAsciiLower in base/strings/string_util.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git sync Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/location.h" 11 #include "base/location.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/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h"
16 #include "base/thread_task_runner_handle.h" 17 #include "base/thread_task_runner_handle.h"
17 #include "build/build_config.h" 18 #include "build/build_config.h"
18 #include "content/browser/browser_thread_impl.h" 19 #include "content/browser/browser_thread_impl.h"
19 #include "content/browser/renderer_host/media/media_stream_manager.h" 20 #include "content/browser/renderer_host/media/media_stream_manager.h"
20 #include "content/browser/renderer_host/media/media_stream_requester.h" 21 #include "content/browser/renderer_host/media/media_stream_requester.h"
21 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 22 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
22 #include "content/common/media/media_stream_options.h" 23 #include "content/common/media/media_stream_options.h"
23 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "media/audio/audio_manager_base.h" 26 #include "media/audio/audio_manager_base.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 const std::string unique_other_id("other-unique-id"); 295 const std::string unique_other_id("other-unique-id");
295 const std::string hashed_other_id = 296 const std::string hashed_other_id =
296 MediaStreamManager::GetHMACForMediaDeviceID( 297 MediaStreamManager::GetHMACForMediaDeviceID(
297 GetMockSaltCallback(), security_origin, unique_other_id); 298 GetMockSaltCallback(), security_origin, unique_other_id);
298 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( 299 EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC(
299 GetMockSaltCallback(), security_origin, hashed_other_id, 300 GetMockSaltCallback(), security_origin, hashed_other_id,
300 unique_other_id)); 301 unique_other_id));
301 EXPECT_NE(unique_other_id, hashed_other_id); 302 EXPECT_NE(unique_other_id, hashed_other_id);
302 EXPECT_EQ(hashed_other_id.size(), 64U); 303 EXPECT_EQ(hashed_other_id.size(), 64U);
303 for (const char& c : hashed_other_id) 304 for (const char& c : hashed_other_id)
304 EXPECT_TRUE((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')); 305 EXPECT_TRUE(base::IsAsciiDigit(c) || (c >= 'a' && c <= 'f'));
305 } 306 }
306 307
307 TEST_F(MediaStreamManagerTest, EnumerationOutputDevices) { 308 TEST_F(MediaStreamManagerTest, EnumerationOutputDevices) {
308 for (size_t num_devices = 0; num_devices < 3; num_devices++) { 309 for (size_t num_devices = 0; num_devices < 3; num_devices++) {
309 audio_manager_->SetNumAudioOutputDevices(num_devices); 310 audio_manager_->SetNumAudioOutputDevices(num_devices);
310 base::RunLoop run_loop; 311 base::RunLoop run_loop;
311 MockMediaStreamRequester requester(&run_loop, 312 MockMediaStreamRequester requester(&run_loop,
312 num_devices == 0 ? 0 : num_devices + 1); 313 num_devices == 0 ? 0 : num_devices + 1);
313 const int render_process_id = 1; 314 const int render_process_id = 1;
314 const int render_frame_id = 1; 315 const int render_frame_id = 1;
315 const int page_request_id = 1; 316 const int page_request_id = 1;
316 const GURL security_origin("http://localhost"); 317 const GURL security_origin("http://localhost");
317 EXPECT_CALL(requester, 318 EXPECT_CALL(requester,
318 MockDevicesEnumerated(render_frame_id, page_request_id, _, _)); 319 MockDevicesEnumerated(render_frame_id, page_request_id, _, _));
319 std::string label = media_stream_manager_->EnumerateDevices( 320 std::string label = media_stream_manager_->EnumerateDevices(
320 &requester, render_process_id, render_frame_id, GetMockSaltCallback(), 321 &requester, render_process_id, render_frame_id, GetMockSaltCallback(),
321 page_request_id, MEDIA_DEVICE_AUDIO_OUTPUT, security_origin); 322 page_request_id, MEDIA_DEVICE_AUDIO_OUTPUT, security_origin);
322 run_loop.Run(); 323 run_loop.Run();
323 // CancelRequest is necessary for enumeration requests. 324 // CancelRequest is necessary for enumeration requests.
324 media_stream_manager_->CancelRequest(label); 325 media_stream_manager_->CancelRequest(label);
325 } 326 }
326 } 327 }
327 328
328 } // namespace content 329 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698