Chromium Code Reviews| Index: content/browser/renderer_host/media/media_stream_manager_unittest.cc |
| diff --git a/content/browser/renderer_host/media/media_stream_manager_unittest.cc b/content/browser/renderer_host/media/media_stream_manager_unittest.cc |
| index fc0028c0a7669faf821b1907404c1b7a585304bc..96a778e709feb1af68787aec205a36c95bd73600 100644 |
| --- a/content/browser/renderer_host/media/media_stream_manager_unittest.cc |
| +++ b/content/browser/renderer_host/media/media_stream_manager_unittest.cc |
| @@ -50,6 +50,17 @@ typedef media::AudioManagerAndroid AudioManagerPlatform; |
| typedef media::FakeAudioManager AudioManagerPlatform; |
| #endif |
| +namespace { |
| + |
| +std::string ReturnMockSalt() { |
| + return std::string(); |
| +} |
| + |
| +ResourceContext::SaltCallback GetMockSaltCallback() { |
| + return base::Bind(&ReturnMockSalt); |
| +} |
| + |
| +} // namespace |
| // This class mocks the audio manager and overrides the |
| // GetAudioInputDeviceNames() method to ensure that we can run our tests on |
| @@ -182,4 +193,37 @@ TEST_F(MediaStreamManagerTest, MakeAndCancelMultipleRequests) { |
| run_loop_.Run(); |
| } |
| +TEST_F(MediaStreamManagerTest, DeviceID) { |
| + GURL security_origin("http://localhost"); |
| + std::string unique_default_id(media::AudioManagerBase::kDefaultDeviceId); |
|
tommi (sloooow) - chröme
2015/09/28 14:30:50
nit: const? (same for unique_communications_id, un
Guido Urdaneta
2015/09/28 14:37:24
Done.
|
| + std::string unique_communications_id( |
| + media::AudioManagerBase::kCommunicationsDeviceId); |
| + std::string unique_other_id("other-unique-id"); |
| + |
| + std::string hashed_default_id = MediaStreamManager::GetHMACForMediaDeviceID( |
| + GetMockSaltCallback(), security_origin, unique_default_id); |
| + EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( |
| + GetMockSaltCallback(), security_origin, hashed_default_id, |
| + unique_default_id)); |
| + EXPECT_EQ(unique_default_id, hashed_default_id); |
| + |
| + std::string hashed_communications_id = |
| + MediaStreamManager::GetHMACForMediaDeviceID( |
| + GetMockSaltCallback(), security_origin, unique_communications_id); |
| + EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( |
| + GetMockSaltCallback(), security_origin, hashed_communications_id, |
| + unique_communications_id)); |
| + EXPECT_EQ(unique_communications_id, hashed_communications_id); |
| + |
| + std::string hashed_other_id = MediaStreamManager::GetHMACForMediaDeviceID( |
| + GetMockSaltCallback(), security_origin, unique_other_id); |
| + EXPECT_TRUE(MediaStreamManager::DoesMediaDeviceIDMatchHMAC( |
| + GetMockSaltCallback(), security_origin, hashed_other_id, |
| + unique_other_id)); |
| + EXPECT_NE(unique_other_id, hashed_other_id); |
| + EXPECT_EQ(hashed_other_id.size(), 64U); |
| + for (const char& c : hashed_other_id) |
| + EXPECT_TRUE((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')); |
| +} |
| + |
| } // namespace content |