Commit ad928ca5 authored by Elliot Glaysher's avatar Elliot Glaysher Committed by Commit Bot

Fix remaining memory errors in services_unittests.

Also enables services_unittests on the linux asan bots.

Bug: 751853
Change-Id: Ia4ea33100405c657fd0ee40fe15306e997193ce8
Reviewed-on: https://chromium-review.googlesource.com/599038Reviewed-by: default avatarEhsan Chiniforooshan <chiniforooshan@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarChristian Fremerey <chfremer@chromium.org>
Commit-Queue: Elliot Glaysher <erg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491785}
parent 732ddfe0
...@@ -47,7 +47,8 @@ class MockRecorder : public mojom::Recorder { ...@@ -47,7 +47,8 @@ class MockRecorder : public mojom::Recorder {
} }
void AddChunk(const std::string& chunk) override { void AddChunk(const std::string& chunk) override {
auto* analyzer = trace_analyzer::TraceAnalyzer::Create("[" + chunk + "]"); std::unique_ptr<trace_analyzer::TraceAnalyzer> analyzer(
trace_analyzer::TraceAnalyzer::Create("[" + chunk + "]"));
trace_analyzer::TraceEventVector events; trace_analyzer::TraceEventVector events;
analyzer->FindEvents(trace_analyzer::Query::EventCategoryIs(kTestCategory), analyzer->FindEvents(trace_analyzer::Query::EventCategoryIs(kTestCategory),
&events); &events);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/run_loop.h" #include "base/run_loop.h"
#include "services/video_capture/test/mock_device_test.h" #include "services/video_capture/test/mock_device_test.h"
using testing::_; using testing::_;
...@@ -17,29 +18,45 @@ using MockVideoCaptureDeviceTest = MockDeviceTest; ...@@ -17,29 +18,45 @@ using MockVideoCaptureDeviceTest = MockDeviceTest;
// Tests that the service stops the capture device when the client closes the // Tests that the service stops the capture device when the client closes the
// connection to the device proxy. // connection to the device proxy.
TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceProxy) { TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceProxy) {
base::RunLoop wait_loop; {
base::RunLoop wait_loop;
EXPECT_CALL(mock_device_, DoStopAndDeAllocate()) EXPECT_CALL(mock_device_, DoStopAndDeAllocate())
.WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
device_proxy_.reset(); device_proxy_.reset();
wait_loop.Run();
}
wait_loop.Run(); // The internals of ReceiverOnTaskRunner perform a DeleteSoon().
{
base::RunLoop wait_loop;
wait_loop.RunUntilIdle();
}
} }
// Tests that the service stops the capture device when the client closes the // Tests that the service stops the capture device when the client closes the
// connection to the client proxy it provided to the service. // connection to the client proxy it provided to the service.
TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceClient) { TEST_F(MockVideoCaptureDeviceTest, DeviceIsStoppedWhenDiscardingDeviceClient) {
base::RunLoop wait_loop; {
base::RunLoop wait_loop;
EXPECT_CALL(mock_device_, DoStopAndDeAllocate()) EXPECT_CALL(mock_device_, DoStopAndDeAllocate())
.WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); })); .WillOnce(Invoke([&wait_loop]() { wait_loop.Quit(); }));
device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_)); device_proxy_->Start(requested_settings_, std::move(mock_receiver_proxy_));
mock_receiver_.reset(); mock_receiver_.reset();
wait_loop.Run();
}
wait_loop.Run(); // The internals of ReceiverOnTaskRunner perform a DeleteSoon().
{
base::RunLoop wait_loop;
wait_loop.RunUntilIdle();
}
} }
// Tests that a utilization reported to a video_capture.mojom.Device via // Tests that a utilization reported to a video_capture.mojom.Device via
......
...@@ -215,6 +215,12 @@ ...@@ -215,6 +215,12 @@
}, },
"test": "sandbox_linux_unittests" "test": "sandbox_linux_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "services_unittests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
...@@ -927,6 +933,12 @@ ...@@ -927,6 +933,12 @@
}, },
"test": "sandbox_linux_unittests" "test": "sandbox_linux_unittests"
}, },
{
"swarming": {
"can_use_on_swarming_builders": true
},
"test": "services_unittests"
},
{ {
"swarming": { "swarming": {
"can_use_on_swarming_builders": true "can_use_on_swarming_builders": true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment