volume_test.cc revision 12dbc23851c95cbabdcafe9789465d8d91a59e81
112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org/*
212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *
412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  Use of this source code is governed by a BSD-style license
512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  that can be found in the LICENSE file in the root of the source
612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  tree. An additional intellectual property rights grant can be found
712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  in the file PATENTS.  All contributing project authors may
812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org */
1012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
1112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org#include "after_streaming_fixture.h"
1212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
1312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgclass VolumeTest : public AfterStreamingFixture {
1412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org protected:
1512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  void SwitchToManualMicrophone() {
1612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    EXPECT_EQ(0, voe_file_->StopPlayingFileAsMicrophone(channel_));
1712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
1812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    TEST_LOG("You need to speak manually into the microphone for this test.\n");
1912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    Sleep(2000);
2012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  }
2112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org};
2212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
2312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, DefaultSpeakerVolumeIsAtMost255) {
2412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  unsigned int volume = 1000;
2512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(volume));
2612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_LE(volume, 255u);
2712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
2812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
2912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualSetVolumeWorks) {
3012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  unsigned int original_volume = 0;
3112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSpeakerVolume(original_volume));
3212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
3312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
3412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting speaker volume to 0 out of 255.\n");
3512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(0));
3612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
3712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
3812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting speaker volume to 100 out of 255.\n");
3912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(100));
4012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
4112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
4212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Set the volume to 255 very briefly so we don't blast the poor user
4312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // listening to this. This is just to test the call succeeds.
4412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(255));
4512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
4612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting speaker volume to the original %d out of 255.\n",
4712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org      original_volume);
4812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSpeakerVolume(original_volume));
4912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
5012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
5112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
5212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org#if !defined(MAC_IPHONE)
5312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
5412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, DefaultMicrophoneVolumeIsAtMost255) {
5512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  unsigned int volume = 1000;
5612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetMicVolume(volume));
5712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_LE(volume, 255u);
5812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
5912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
6012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualRequiresMicrophoneCanSetMicrophoneVolumeWithAcgOff) {
6112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  SwitchToManualMicrophone();
6212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_apm_->SetAgcStatus(false));
6312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
6412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  unsigned int original_volume = 0;
6512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetMicVolume(original_volume));
6612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
6712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting microphone volume to 0.\n");
6812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetMicVolume(channel_));
6912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
7012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting microphone volume to 255.\n");
7112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetMicVolume(255));
7212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
7312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Setting microphone volume back to saved value.\n");
7412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetMicVolume(original_volume));
7512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
7612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
7712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
7812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ChannelScalingIsOneByDefault) {
7912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float scaling = -1.0;
8012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
8112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetChannelOutputVolumeScaling(
8212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org      channel_, scaling));
8312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(1.0, scaling);
8412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
8512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
8612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualCanSetChannelScaling) {
8712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetChannelOutputVolumeScaling(
8812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org      channel_, 0.1));
8912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
9012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float scaling = 1.0;
9112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetChannelOutputVolumeScaling(
9212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org      channel_, scaling));
9312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
9412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(0.1, scaling);
9512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
9612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Channel scaling set to 0.1: audio should be barely audible.\n");
9712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
9812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
9912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
10012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org#endif  // !MAC_IPHONE
10112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
10212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org#if !defined(WEBRTC_ANDROID) && !defined(MAC_IPHONE)
10312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
10412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, InputMutingIsNotEnabledByDefault) {
10512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = true;
10612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted));
10712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
10812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
10912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
11012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualInputMutingMutesMicrophone) {
11112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  SwitchToManualMicrophone();
11212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
11312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Enable muting.
11412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, true));
11512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = false;
11612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted));
11712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_TRUE(is_muted);
11812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
11912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Muted: talk into microphone and verify you can't hear yourself.\n");
12012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
12112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
12212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Test that we can disable muting.
12312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetInputMute(channel_, false));
12412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetInputMute(channel_, is_muted));
12512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
12612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
12712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Unmuted: talk into microphone and verify you can hear yourself.\n");
12812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
12912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
13012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
13112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, SystemInputMutingIsNotEnabledByDefault) {
13212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = true;
13312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted));
13412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
13512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
13612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
13712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualSystemInputMutingMutesMicrophone) {
13812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  SwitchToManualMicrophone();
13912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
14012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Enable system input muting.
14112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSystemInputMute(true));
14212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = false;
14312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted));
14412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_TRUE(is_muted);
14512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
14612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Muted: talk into microphone and verify you can't hear yourself.\n");
14712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
14812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
14912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Test that we can disable system input muting.
15012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSystemInputMute(false));
15112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemInputMute(is_muted));
15212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
15312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
15412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Unmuted: talk into microphone and verify you can hear yourself.\n");
15512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
15612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
15712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
15812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, SystemOutputMutingIsNotEnabledByDefault) {
15912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = true;
16012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted));
16112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
16212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
16312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
16412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualSystemOutputMutingMutesOutput) {
16512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Enable muting.
16612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSystemOutputMute(true));
16712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  bool is_muted = false;
16812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted));
16912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_TRUE(is_muted);
17012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
17112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Muted: you should hear no audio.\n");
17212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
17312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
17412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // Test that we can disable muting.
17512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetSystemOutputMute(false));
17612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetSystemOutputMute(is_muted));
17712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FALSE(is_muted);
17812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
17912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Unmuted: you should hear audio.\n");
18012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(2000);
18112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
18212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
18312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualTestInputAndOutputLevels) {
18412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  SwitchToManualMicrophone();
18512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
18612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Speak and verify that the following levels look right:\n");
18712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  for (int i = 0; i < 5; i++) {
18812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    Sleep(1000);
18912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    unsigned int input_level = 0;
19012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    unsigned int output_level = 0;
19112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    unsigned int input_level_full_range = 0;
19212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    unsigned int output_level_full_range = 0;
19312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
19412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    EXPECT_EQ(0, voe_volume_control_->GetSpeechInputLevel(
19512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        input_level));
19612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    EXPECT_EQ(0, voe_volume_control_->GetSpeechOutputLevel(
19712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        channel_, output_level));
19812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    EXPECT_EQ(0, voe_volume_control_->GetSpeechInputLevelFullRange(
19912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        input_level_full_range));
20012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    EXPECT_EQ(0, voe_volume_control_->GetSpeechOutputLevelFullRange(
20112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        channel_, output_level_full_range));
20212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
20312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    TEST_LOG("    warped levels (0-9)    : in=%5d, out=%5d\n",
20412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        input_level, output_level);
20512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org    TEST_LOG("    linear levels (0-32768): in=%5d, out=%5d\n",
20612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org        input_level_full_range, output_level_full_range);
20712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  }
20812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
20912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
21012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ChannelsAreNotPannedByDefault) {
21112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float left = -1.0;
21212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float right = -1.0;
21312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
21412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetOutputVolumePan(channel_, left, right));
21512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(1.0, left);
21612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(1.0, right);
21712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
21812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
21912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.orgTEST_F(VolumeTest, ManualTestChannelPanning) {
22012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Panning left.\n");
22112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 0.8, 0.1));
22212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
22312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
22412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Back to center.\n");
22512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 1.0, 1.0));
22612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
22712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
22812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  TEST_LOG("Panning right.\n");
22912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->SetOutputVolumePan(channel_, 0.1, 0.8));
23012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  Sleep(1000);
23112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
23212dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  // To finish, verify that the getter works.
23312dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float left = 0.0;
23412dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  float right = 0.0;
23512dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
23612dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_EQ(0, voe_volume_control_->GetOutputVolumePan(channel_, left, right));
23712dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(0.1, left);
23812dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org  EXPECT_FLOAT_EQ(0.8, right);
23912dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org}
24012dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org
24112dbc23851c95cbabdcafe9789465d8d91a59e81phoglund@webrtc.org#endif  // !WEBRTC_ANDROID && !MAC_IPHONE
242