Commit 4358811e authored by Robert Liao's avatar Robert Liao Committed by Commit Bot

Remove ReleaseAndGetAddressOf from //media/base/win/test_utils.h

BUG=914910

Change-Id: I8e7dbaddd01ea2bcfa9d1c177dde6008cd26e7c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2285080
Commit-Queue: Robert Liao <robliao@chromium.org>
Auto-Submit: Robert Liao <robliao@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786009}
parent 532cb200
......@@ -69,5 +69,6 @@ source_set("test_support") {
deps = [
"//base",
"//testing/gmock",
"//testing/gtest",
]
}
......@@ -5,10 +5,13 @@
#ifndef MEDIA_BASE_WIN_TEST_UTILS_H_
#define MEDIA_BASE_WIN_TEST_UTILS_H_
#include <type_traits>
#include <wrl/client.h>
#include <wrl/implements.h>
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#define MOCK_STDCALL_METHOD0(Name, Types) \
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, Name, Types)
......@@ -86,12 +89,11 @@ ACTION_TEMPLATE(SetComPointeeAndReturnOk,
ACTION_TEMPLATE(SaveComPtr,
HAS_1_TEMPLATE_PARAMS(int, k),
AND_1_VALUE_PARAMS(p)) {
// ComPtr::operator& is overloaded. This to make sure we don't get const
// Details::ComPtrRef.
auto com_ptr_ref = p;
auto** ptr = com_ptr_ref.ReleaseAndGetAddressOf();
*ptr = std::get<k>(args);
(*ptr)->AddRef();
auto* value = std::get<k>(args);
using InterfaceType = typename std::remove_pointer<decltype(value)>::type;
Microsoft::WRL::ComPtr<InterfaceType> result(value);
if (FAILED(result.As(p)))
ADD_FAILURE() << "InterfaceType Value Type Mismatched.";
}
// Use this function to create a mock so that they are ref-counted correctly.
......
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