Removed Die mock from MockAudioEncoder

MockAudioEncoder was calling a mocked Die function on itself in its
destructor. This outputs "Uninteresting mock function call" warning if
the Die call was not expected. This is true even if a NiceMock is used
to suppress the warnings.

The purpose of testing that the destructor is called might be to protect
against memory leaks when audio encoder ownership is transferred using a
raw pointer. However, this case is already covered by msan checks.

Bug: None
Change-Id: I0603c417b4b239027859228e05ebcf83ff5aaf18
Reviewed-on: https://webrtc-review.googlesource.com/56183
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22146}
diff --git a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
index 4f16ff4..86fba1d 100644
--- a/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
+++ b/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc
@@ -65,7 +65,6 @@
     auto enc = rtc::MakeUnique<testing::StrictMock<MockAudioEncoder>>();
     EXPECT_CALL(*enc, SampleRateHz())
         .WillOnce(testing::Return(Params::CodecInfo().sample_rate_hz));
-    EXPECT_CALL(*enc, Die());
     return std::move(enc);
   }
 };
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index cc37b81..17f7926 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -1811,7 +1811,6 @@
   MockAudioEncoder mock_encoder;
   // Set expectations on the mock encoder and also delegate the calls to the
   // real encoder.
-  EXPECT_CALL(mock_encoder, Die());
   EXPECT_CALL(mock_encoder, SampleRateHz())
       .Times(AtLeast(1))
       .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SampleRateHz));
diff --git a/modules/audio_coding/acm2/codec_manager_unittest.cc b/modules/audio_coding/acm2/codec_manager_unittest.cc
index e041b5e..6a5ea5f 100644
--- a/modules/audio_coding/acm2/codec_manager_unittest.cc
+++ b/modules/audio_coding/acm2/codec_manager_unittest.cc
@@ -28,7 +28,6 @@
   EXPECT_CALL(*enc, SampleRateHz()).WillRepeatedly(Return(8000));
   EXPECT_CALL(*enc, NumChannels()).WillRepeatedly(Return(1));
   EXPECT_CALL(*enc, Max10MsFramesInAPacket()).WillRepeatedly(Return(1));
-  EXPECT_CALL(*enc, Die());
   return enc;
 }
 
diff --git a/modules/audio_coding/acm2/rent_a_codec_unittest.cc b/modules/audio_coding/acm2/rent_a_codec_unittest.cc
index 9eded20..c949c1c 100644
--- a/modules/audio_coding/acm2/rent_a_codec_unittest.cc
+++ b/modules/audio_coding/acm2/rent_a_codec_unittest.cc
@@ -137,7 +137,6 @@
         .WillOnce(Return(info));
     EXPECT_CALL(marker, Mark("A"));
     EXPECT_CALL(marker, Mark("B"));
-    EXPECT_CALL(*external_encoder, Die());
     EXPECT_CALL(marker, Mark("C"));
   }
 
@@ -180,11 +179,9 @@
   {
     ::testing::InSequence s;
     EXPECT_CALL(marker, Mark("disabled"));
-    EXPECT_CALL(*speech_encoder1, Die());
     EXPECT_CALL(marker, Mark("enabled"));
     if (use_cng || use_red)
       EXPECT_CALL(*speech_encoder2, Reset());
-    EXPECT_CALL(*speech_encoder2, Die());
   }
 
   RentACodec::StackParameters param1, param2;
diff --git a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index 6e246c9..f85abe2 100644
--- a/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -43,7 +43,6 @@
         sample_rate_hz_(8000) {
     memset(audio_, 0, kMaxNumSamples * 2);
     EXPECT_CALL(*mock_encoder_, NumChannels()).WillRepeatedly(Return(1));
-    EXPECT_CALL(*mock_encoder_, Die()).Times(1);
   }
 
   void TearDown() override {
diff --git a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
index 79d205e..64bafd2 100644
--- a/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
+++ b/modules/audio_coding/codecs/red/audio_encoder_copy_red_unittest.cc
@@ -49,7 +49,6 @@
   }
 
   void TearDown() override {
-    EXPECT_CALL(*mock_encoder_, Die()).Times(1);
     red_.reset();
   }
 
diff --git a/test/mock_audio_encoder.cc b/test/mock_audio_encoder.cc
index cd89bdd..3661511 100644
--- a/test/mock_audio_encoder.cc
+++ b/test/mock_audio_encoder.cc
@@ -13,9 +13,7 @@
 namespace webrtc {
 
 MockAudioEncoder::MockAudioEncoder() = default;
-MockAudioEncoder::~MockAudioEncoder() {
-  Die();
-}
+MockAudioEncoder::~MockAudioEncoder() = default;
 
 MockAudioEncoder::FakeEncoding::FakeEncoding(
     const AudioEncoder::EncodedInfo& info)
diff --git a/test/mock_audio_encoder.h b/test/mock_audio_encoder.h
index 8196cf1..7154e64 100644
--- a/test/mock_audio_encoder.h
+++ b/test/mock_audio_encoder.h
@@ -27,7 +27,6 @@
   // http://crbug.com/428099.
   MockAudioEncoder();
   ~MockAudioEncoder();
-  MOCK_METHOD0(Die, void());
   MOCK_METHOD1(Mark, void(std::string desc));
   MOCK_CONST_METHOD0(SampleRateHz, int());
   MOCK_CONST_METHOD0(NumChannels, size_t());