OLD | NEW |
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 class MediaStreamDevicesControllerTest : public WebRtcTestBase { | 32 class MediaStreamDevicesControllerTest : public WebRtcTestBase { |
33 public: | 33 public: |
34 // TODO(raymes): When crbug.com/606138 is finished and the | 34 // TODO(raymes): When crbug.com/606138 is finished and the |
35 // PermissionRequestManager is used to show all prompts on Android/Desktop | 35 // PermissionRequestManager is used to show all prompts on Android/Desktop |
36 // we should remove PermissionPromptDelegate and just use | 36 // we should remove PermissionPromptDelegate and just use |
37 // MockPermissionPromptFactory instead. The APIs are the same. | 37 // MockPermissionPromptFactory instead. The APIs are the same. |
38 class TestPermissionPromptDelegate | 38 class TestPermissionPromptDelegate |
39 : public internal::PermissionPromptDelegate { | 39 : public MediaStreamDevicesController::PermissionPromptDelegate { |
40 public: | 40 public: |
41 void ShowPrompt( | 41 void ShowPrompt(bool user_gesture, |
42 bool user_gesture, | 42 content::WebContents* web_contents, |
43 content::WebContents* web_contents, | 43 std::unique_ptr<MediaStreamDevicesController::Request> |
44 std::unique_ptr<MediaStreamDevicesController> controller) override { | 44 request) override { |
45 if (controller->IsAskingForAudio()) | 45 if (request->IsAskingForAudio()) |
46 last_requests_.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 46 last_requests_.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
47 if (controller->IsAskingForVideo()) | 47 if (request->IsAskingForVideo()) |
48 last_requests_.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 48 last_requests_.push_back(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
49 | 49 |
50 if (response_type_ == PermissionRequestManager::ACCEPT_ALL) | 50 if (response_type_ == PermissionRequestManager::ACCEPT_ALL) |
51 controller->PermissionGranted(); | 51 request->PermissionGranted(); |
52 else if (response_type_ == PermissionRequestManager::DENY_ALL) | 52 else if (response_type_ == PermissionRequestManager::DENY_ALL) |
53 controller->PermissionDenied(); | 53 request->PermissionDenied(); |
54 } | 54 } |
55 | 55 |
56 void set_response_type( | 56 void set_response_type( |
57 PermissionRequestManager::AutoResponseType response_type) { | 57 PermissionRequestManager::AutoResponseType response_type) { |
58 response_type_ = response_type; | 58 response_type_ = response_type; |
59 } | 59 } |
60 | 60 |
61 size_t TotalRequestCount() { return last_requests_.size(); } | 61 size_t TotalRequestCount() { return last_requests_.size(); } |
62 | 62 |
63 bool WasRequested(ContentSettingsType type) { | 63 bool WasRequested(ContentSettingsType type) { |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), | 802 GetWebContents(), CreateRequest(example_audio_id(), example_video_id()), |
803 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 803 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
804 base::Unretained(this))); | 804 base::Unretained(this))); |
805 | 805 |
806 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); | 806 ASSERT_EQ(0u, prompt_delegate()->TotalRequestCount()); |
807 | 807 |
808 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); | 808 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); |
809 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 809 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
810 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 810 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
811 } | 811 } |
OLD | NEW |