chromeos-dbus-bindings: Generate new gmock methods

For historical reasons, chromeos-dbus-bindings generator outputs
the code with old gmock macros.
This CL updates it to generate new gmock macros.

BUG=b:288402584
TEST=Tryjob

Change-Id: I9a3cc6199f3975649c247f0253a80a28763cfc06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4644854
Tested-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Grace Cham <hscham@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
NOKEYCHECK=True
GitOrigin-RevId: dc8c85dc5c1ca8b211bea72e6448882fb3df9652
diff --git a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/genutil/genutil.go b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/genutil/genutil.go
index 64536be..c97aa51 100644
--- a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/genutil/genutil.go
+++ b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/genutil/genutil.go
@@ -89,6 +89,12 @@
 	return s
 }
 
+// Indent returns string with indent.
+func Indent(i int, s string) string {
+	indent := "\n" + strings.Repeat(" ", i)
+	return strings.ReplaceAll(s, "\n", indent)
+}
+
 // Nindent returns string with indent, prefixed by a NL.
 func Nindent(i int, s string) string {
 	lines := strings.Split(s, "\n")
diff --git a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock.go b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock.go
index 135a6c2..d0834c0 100644
--- a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock.go
+++ b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock.go
@@ -5,7 +5,9 @@
 package proxy
 
 import (
+	"fmt"
 	"io"
+	"strings"
 	"text/template"
 
 	"go.chromium.org/chromiumos/dbusbindings/generate/genutil"
@@ -49,90 +51,76 @@
   {{$mockName}}() = default;
   {{$mockName}}(const {{$mockName}}&) = delete;
   {{$mockName}}& operator=(const {{$mockName}}&) = delete;
-{{range .Methods -}}
-{{- $inParams := makeMockMethodParams .InputArguments -}}
-{{- $outParams := makeMockMethodParams .OutputArguments -}}
-{{- $arity := gmockArity (len $inParams) (len $outParams) -}}
-{{- /* TODO(crbug.com/983008): The following format is to make the output compatible with C++. */}}
-{{- if ge $arity.Sync 11}}
-{{- /* TODO(crbug.com/983008): Old gmock does not support arity >= 11. So this is workaround. */ -}}
-{{- $indent := repeat " " (add (len "  bool (") (len .Name))}}
-  bool {{.Name}}(
-{{- range $inParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-{{$indent}}{{end -}}
-{{- range $outParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-{{$indent}}{{end -}}
-brillo::ErrorPtr* /*error*/,
-{{$indent}}int /*timeout_ms*/) override {
-    LOG(WARNING) << "{{.Name}}(): gmock can't handle methods with {{$arity.Sync}} arguments. You can override this method in a subclass if you need to.";
-    return false;
-  }
-{{- else}}
-  MOCK_METHOD{{$arity.Sync}}({{.Name}},
-               {{if ge $arity.Sync 10}} {{end}}bool(
-{{- range $inParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-                    {{if ge $arity.Sync 10}} {{end}}{{end -}}
-{{- range $outParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-                    {{if ge $arity.Sync 10}} {{end}}{{end -}}
-                    brillo::ErrorPtr* /*error*/,
-                    {{if ge $arity.Sync 10}} {{end}}int /*timeout_ms*/));
+{{- range .Methods}}
+{{- $inParams := makeMockMethodParams .InputArguments}}
+{{- $outParams := makeMockMethodParams .OutputArguments}}
+
+  MOCK_METHOD(bool,
+              {{.Name}},
+              ({{- range $inParams}}{{maybeWrap .Type}}{{if .Name}} {{.Name}}{{end}},
+               {{end -}}
+               {{- range $outParams}}{{maybeWrap .Type}}{{if .Name}} {{.Name}}{{end}},
+               {{end -}}
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              {{.Name}}Async,
+              ({{- range $inParams}}{{maybeWrap .Type}}{{if .Name}} {{.Name}}{{end}},
+               {{end -}}
+               {{- makeMethodCallbackType .OutputArguments | maybeWrap}} /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
 {{- end}}
-{{- if ge $arity.Async 11}}
-{{- /* TODO(crbug.com/983008): Old gmock does not support arity >= 11. So this is workaround. */ -}}
-{{- $indent := repeat " " (add 13 (len .Name))}}
-  void {{.Name}}Async(
-{{- range $inParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-{{$indent}}{{end -}}
-{{makeMethodCallbackType .OutputArguments}} /*success_callback*/,
-{{$indent}}base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-{{$indent}}int /*timeout_ms*/) override {
-    LOG(WARNING) << "{{.Name}}Async(): gmock can't handle methods with {{$arity.Async}} arguments. You can override this method in a subclass if you need to.";
-  }
-{{- else}}
-  MOCK_METHOD{{$arity.Async}}({{.Name}}Async,
-               {{if ge $arity.Async 10}} {{end}}void(
-{{- range $inParams -}}
-{{.Type}}{{if .Name}} {{.Name}}{{end}},
-                    {{if ge $arity.Async 10}} {{end}}{{end -}}
-                    {{makeMethodCallbackType .OutputArguments}} /*success_callback*/,
-                    {{if ge $arity.Async 10}} {{end}}base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    {{if ge $arity.Async 10}} {{end}}int /*timeout_ms*/));
-{{- end}}
-{{- end}}
+
 {{- range .Signals}}
+
+  {{/* TODO(b/288402584): get rid of DoRegister* function */ -}}
   void Register{{.Name}}SignalHandler(
     {{- /* TODO(crbug.com/983008): fix the indent to meet style guide. */ -}}
     {{- makeSignalCallbackType .Args | nindent 4}} signal_callback,
-    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) {
+    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) override {
     DoRegister{{.Name}}SignalHandler(signal_callback, &on_connected_callback);
   }
-  MOCK_METHOD2(DoRegister{{.Name}}SignalHandler,
-               void({{makeSignalCallbackType .Args | nindent 20 | trimLeft " \n"}} /*signal_callback*/,
-                    dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
+  MOCK_METHOD(void,
+              DoRegister{{.Name}}SignalHandler,
+              ({{makeSignalCallbackType .Args | nindent 15 | trimLeft " \n"}} /*signal_callback*/,
+               dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
 {{- end}}
+
 {{- range .Properties}}
 {{- $name := makePropertyVariableName . | makeVariableName -}}
 {{- $type := makeProxyInArgTypeProxy . }}
-  MOCK_CONST_METHOD0({{$name}}, {{$type}}());
-  MOCK_CONST_METHOD0(is_{{$name}}_valid, bool());
+
+  MOCK_METHOD({{$type}}, {{$name}}, (), (const, override));
+  MOCK_METHOD(bool, is_{{$name}}_valid, (), (const, override));
+
 {{- if eq .Access "readwrite"}}
-  MOCK_METHOD2(set_{{$name}}, void({{$type}}, base::OnceCallback<void(bool)>));
+  MOCK_METHOD(void,
+              set_{{$name}},
+              ({{maybeWrap $type}}, base::OnceCallback<void(bool)>),
+              (override));
 {{- end}}
 {{- end}}
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 {{- if .Properties}}
 {{- if $.ObjectManagerName }}
-  MOCK_METHOD1(SetPropertyChangedCallback,
-               void(const base::RepeatingCallback<void({{$itfName}}*, const std::string&)>&));
+
+  MOCK_METHOD(void,
+              SetPropertyChangedCallback,
+              ((const base::RepeatingCallback<void({{$itfName}}*,
+                                                   const std::string&)>&)),
+              (override));
 {{- else}}
-  MOCK_METHOD1(InitializeProperties,
-               void(const base::RepeatingCallback<void({{$itfName}}*, const std::string&)>&));
+
+  MOCK_METHOD(void,
+              InitializeProperties,
+              ((const base::RepeatingCallback<void({{$itfName}}*,
+                                                   const std::string&)>&)),
+              (override));
 {{- end}}
 {{- end}}
 };
@@ -152,16 +140,15 @@
 		mockFuncMap[k] = v
 	}
 
-	type gmockArity struct {
-		Sync, Async int
-	}
-	mockFuncMap["gmockArity"] = func(nInArgs, nOutArgs int) gmockArity {
-		return gmockArity{
-			Sync:  nInArgs + nOutArgs + 2, // error and timeout.
-			Async: nInArgs + 3,            // success_callback, error_callback and timeout
+	// Mock argument type must not contain commas, or needs to be wrapped
+	// by parens. E.g., "std::pair<int, int>" needs to be "(std::pair<int, int>)".
+	mockFuncMap["maybeWrap"] = func(typ string) string {
+		if !strings.Contains(typ, ",") {
+			return typ
 		}
+		// Wrap with a pair of parens. Also, tweak the indent.
+		return fmt.Sprintf("(%s)", strings.ReplaceAll(typ, "\n", "\n "))
 	}
-
 	tmpl, err := template.New("mock").Funcs(mockFuncMap).Parse(mockTemplateText)
 	if err != nil {
 		return err
diff --git a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock_test.go b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock_test.go
index 68b1899..84b3e44 100644
--- a/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock_test.go
+++ b/go/src/go.chromium.org/chromiumos/dbusbindings/generate/proxy/mock_test.go
@@ -193,42 +193,60 @@
   InterfaceProxyMock(const InterfaceProxyMock&) = delete;
   InterfaceProxyMock& operator=(const InterfaceProxyMock&) = delete;
 
-  MOCK_METHOD3(Scan,
-               bool(const std::vector<base::ScopedFD>& /*in_args*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD4(ScanAsync,
-               void(const std::vector<base::ScopedFD>& /*in_args*/,
-                    base::OnceCallback<void()> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD3(PassMeProtos,
-               bool(const PassMeProtosRequest& /*in_request*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD4(PassMeProtosAsync,
-               void(const PassMeProtosRequest& /*in_request*/,
-                    base::OnceCallback<void()> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
+  MOCK_METHOD(bool,
+              Scan,
+              (const std::vector<base::ScopedFD>& /*in_args*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              ScanAsync,
+              (const std::vector<base::ScopedFD>& /*in_args*/,
+               base::OnceCallback<void()> /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              PassMeProtos,
+              (const PassMeProtosRequest& /*in_request*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              PassMeProtosAsync,
+              (const PassMeProtosRequest& /*in_request*/,
+               base::OnceCallback<void()> /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
   void RegisterBSSRemovedSignalHandler(
     const base::RepeatingCallback<void(const YetAnotherProto&,
                                        const std::tuple<int32_t, base::ScopedFD>&)>& signal_callback,
-    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) {
+    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) override {
     DoRegisterBSSRemovedSignalHandler(signal_callback, &on_connected_callback);
   }
-  MOCK_METHOD2(DoRegisterBSSRemovedSignalHandler,
-               void(const base::RepeatingCallback<void(const YetAnotherProto&,
-                                                       const std::tuple<int32_t, base::ScopedFD>&)>& /*signal_callback*/,
-                    dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
-  MOCK_CONST_METHOD0(capabilities, const brillo::VariantDictionary&());
-  MOCK_CONST_METHOD0(is_capabilities_valid, bool());
-  MOCK_CONST_METHOD0(bluetooth_class, uint32_t());
-  MOCK_CONST_METHOD0(is_bluetooth_class_valid, bool());
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
-  MOCK_METHOD1(SetPropertyChangedCallback,
-               void(const base::RepeatingCallback<void(InterfaceProxyInterface*, const std::string&)>&));
+  MOCK_METHOD(void,
+              DoRegisterBSSRemovedSignalHandler,
+              (const base::RepeatingCallback<void(const YetAnotherProto&,
+                                                  const std::tuple<int32_t, base::ScopedFD>&)>& /*signal_callback*/,
+               dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
+
+  MOCK_METHOD(const brillo::VariantDictionary&, capabilities, (), (const, override));
+  MOCK_METHOD(bool, is_capabilities_valid, (), (const, override));
+
+  MOCK_METHOD(uint32_t, bluetooth_class, (), (const, override));
+  MOCK_METHOD(bool, is_bluetooth_class_valid, (), (const, override));
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
+
+  MOCK_METHOD(void,
+              SetPropertyChangedCallback,
+              ((const base::RepeatingCallback<void(InterfaceProxyInterface*,
+                                                   const std::string&)>&)),
+              (override));
 };
 }  // namespace wpa_supplicant1
 }  // namespace w1
@@ -253,8 +271,8 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -313,8 +331,8 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -364,8 +382,8 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -516,160 +534,200 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_METHOD2(MethodNoArg,
-               bool(brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD3(MethodNoArgAsync,
-               void(base::OnceCallback<void()> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD6(MethodWithInArgs,
-               bool(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    const std::tuple<int32_t, base::ScopedFD>& /*in_iarg3*/,
-                    const RequestProto& /*in_iprotoArg*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD7(MethodWithInArgsAsync,
-               void(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    const std::tuple<int32_t, base::ScopedFD>& /*in_iarg3*/,
-                    const RequestProto& /*in_iprotoArg*/,
-                    base::OnceCallback<void()> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD6(MethodWithOutArgs,
-               bool(int64_t* /*out_oarg1*/,
-                    std::vector<uint8_t>* /*out_oarg2*/,
-                    std::tuple<int32_t, base::ScopedFD>* /*out_oarg3*/,
-                    ResponseProto* /*out_oprotoArg*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD3(MethodWithOutArgsAsync,
-               void(base::OnceCallback<void(int64_t /*oarg1*/, const std::vector<uint8_t>& /*oarg2*/, const std::tuple<int32_t, base::ScopedFD>& /*oarg3*/, const ResponseProto& /*oprotoArg*/)> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD6(MethodWithBothArgs,
-               bool(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    uint16_t* /*out_oarg1*/,
-                    double* /*out_oarg2*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD5(MethodWithBothArgsAsync,
-               void(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    base::OnceCallback<void(uint16_t /*oarg1*/, double /*oarg2*/)> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD6(MethodWithMixedArgs,
-               bool(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    uint16_t* /*out_oarg1*/,
-                    double* /*out_oarg2*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD5(MethodWithMixedArgsAsync,
-               void(int64_t /*in_iarg1*/,
-                    const std::vector<uint8_t>& /*in_iarg2*/,
-                    base::OnceCallback<void(uint16_t /*oarg1*/, double /*oarg2*/)> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD9(MethodArity5_2,
-               bool(int64_t /*in_iarg1*/,
-                    int64_t /*in_iarg2*/,
-                    int64_t /*in_iarg3*/,
-                    int64_t /*in_iarg4*/,
-                    int64_t /*in_iarg5*/,
-                    int64_t* /*out_oarg1*/,
-                    int64_t* /*out_oarg2*/,
-                    brillo::ErrorPtr* /*error*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD8(MethodArity5_2Async,
-               void(int64_t /*in_iarg1*/,
-                    int64_t /*in_iarg2*/,
-                    int64_t /*in_iarg3*/,
-                    int64_t /*in_iarg4*/,
-                    int64_t /*in_iarg5*/,
-                    base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  MOCK_METHOD10(MethodArity6_2,
-                bool(int64_t /*in_iarg1*/,
-                     int64_t /*in_iarg2*/,
-                     int64_t /*in_iarg3*/,
-                     int64_t /*in_iarg4*/,
-                     int64_t /*in_iarg5*/,
-                     int64_t /*in_iarg6*/,
-                     int64_t* /*out_oarg1*/,
-                     int64_t* /*out_oarg2*/,
-                     brillo::ErrorPtr* /*error*/,
-                     int /*timeout_ms*/));
-  MOCK_METHOD9(MethodArity6_2Async,
-               void(int64_t /*in_iarg1*/,
-                    int64_t /*in_iarg2*/,
-                    int64_t /*in_iarg3*/,
-                    int64_t /*in_iarg4*/,
-                    int64_t /*in_iarg5*/,
-                    int64_t /*in_iarg6*/,
-                    base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)> /*success_callback*/,
-                    base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                    int /*timeout_ms*/));
-  bool MethodArity7_2(int64_t /*in_iarg1*/,
-                      int64_t /*in_iarg2*/,
-                      int64_t /*in_iarg3*/,
-                      int64_t /*in_iarg4*/,
-                      int64_t /*in_iarg5*/,
-                      int64_t /*in_iarg6*/,
-                      int64_t /*in_iarg7*/,
-                      int64_t* /*out_oarg1*/,
-                      int64_t* /*out_oarg2*/,
-                      brillo::ErrorPtr* /*error*/,
-                      int /*timeout_ms*/) override {
-    LOG(WARNING) << "MethodArity7_2(): gmock can't handle methods with 11 arguments. You can override this method in a subclass if you need to.";
-    return false;
-  }
-  MOCK_METHOD10(MethodArity7_2Async,
-                void(int64_t /*in_iarg1*/,
-                     int64_t /*in_iarg2*/,
-                     int64_t /*in_iarg3*/,
-                     int64_t /*in_iarg4*/,
-                     int64_t /*in_iarg5*/,
-                     int64_t /*in_iarg6*/,
-                     int64_t /*in_iarg7*/,
-                     base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)> /*success_callback*/,
-                     base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                     int /*timeout_ms*/));
-  bool MethodArity8_2(int64_t /*in_iarg1*/,
-                      int64_t /*in_iarg2*/,
-                      int64_t /*in_iarg3*/,
-                      int64_t /*in_iarg4*/,
-                      int64_t /*in_iarg5*/,
-                      int64_t /*in_iarg6*/,
-                      int64_t /*in_iarg7*/,
-                      int64_t /*in_iarg8*/,
-                      int64_t* /*out_oarg1*/,
-                      int64_t* /*out_oarg2*/,
-                      brillo::ErrorPtr* /*error*/,
-                      int /*timeout_ms*/) override {
-    LOG(WARNING) << "MethodArity8_2(): gmock can't handle methods with 12 arguments. You can override this method in a subclass if you need to.";
-    return false;
-  }
-  void MethodArity8_2Async(int64_t /*in_iarg1*/,
-                           int64_t /*in_iarg2*/,
-                           int64_t /*in_iarg3*/,
-                           int64_t /*in_iarg4*/,
-                           int64_t /*in_iarg5*/,
-                           int64_t /*in_iarg6*/,
-                           int64_t /*in_iarg7*/,
-                           int64_t /*in_iarg8*/,
-                           base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)> /*success_callback*/,
-                           base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
-                           int /*timeout_ms*/) override {
-    LOG(WARNING) << "MethodArity8_2Async(): gmock can't handle methods with 11 arguments. You can override this method in a subclass if you need to.";
-  }
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+  MOCK_METHOD(bool,
+              MethodNoArg,
+              (brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodNoArgAsync,
+              (base::OnceCallback<void()> /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodWithInArgs,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               (const std::tuple<int32_t, base::ScopedFD>&) /*in_iarg3*/,
+               const RequestProto& /*in_iprotoArg*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodWithInArgsAsync,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               (const std::tuple<int32_t, base::ScopedFD>&) /*in_iarg3*/,
+               const RequestProto& /*in_iprotoArg*/,
+               base::OnceCallback<void()> /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodWithOutArgs,
+              (int64_t* /*out_oarg1*/,
+               std::vector<uint8_t>* /*out_oarg2*/,
+               (std::tuple<int32_t, base::ScopedFD>*) /*out_oarg3*/,
+               ResponseProto* /*out_oprotoArg*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodWithOutArgsAsync,
+              ((base::OnceCallback<void(int64_t /*oarg1*/, const std::vector<uint8_t>& /*oarg2*/, const std::tuple<int32_t, base::ScopedFD>& /*oarg3*/, const ResponseProto& /*oprotoArg*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodWithBothArgs,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               uint16_t* /*out_oarg1*/,
+               double* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodWithBothArgsAsync,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               (base::OnceCallback<void(uint16_t /*oarg1*/, double /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodWithMixedArgs,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               uint16_t* /*out_oarg1*/,
+               double* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodWithMixedArgsAsync,
+              (int64_t /*in_iarg1*/,
+               const std::vector<uint8_t>& /*in_iarg2*/,
+               (base::OnceCallback<void(uint16_t /*oarg1*/, double /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodArity5_2,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t* /*out_oarg1*/,
+               int64_t* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodArity5_2Async,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               (base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodArity6_2,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               int64_t* /*out_oarg1*/,
+               int64_t* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodArity6_2Async,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               (base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodArity7_2,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               int64_t /*in_iarg7*/,
+               int64_t* /*out_oarg1*/,
+               int64_t* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodArity7_2Async,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               int64_t /*in_iarg7*/,
+               (base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(bool,
+              MethodArity8_2,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               int64_t /*in_iarg7*/,
+               int64_t /*in_iarg8*/,
+               int64_t* /*out_oarg1*/,
+               int64_t* /*out_oarg2*/,
+               brillo::ErrorPtr* /*error*/,
+               int /*timeout_ms*/),
+              (override));
+  MOCK_METHOD(void,
+              MethodArity8_2Async,
+              (int64_t /*in_iarg1*/,
+               int64_t /*in_iarg2*/,
+               int64_t /*in_iarg3*/,
+               int64_t /*in_iarg4*/,
+               int64_t /*in_iarg5*/,
+               int64_t /*in_iarg6*/,
+               int64_t /*in_iarg7*/,
+               int64_t /*in_iarg8*/,
+               (base::OnceCallback<void(int64_t /*oarg1*/, int64_t /*oarg2*/)>) /*success_callback*/,
+               base::OnceCallback<void(brillo::Error*)> /*error_callback*/,
+               int /*timeout_ms*/),
+              (override));
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -754,25 +812,29 @@
   void RegisterSignal1SignalHandler(
     const base::RepeatingCallback<void(const YetAnotherProto&,
                                        const std::tuple<int32_t, base::ScopedFD>&)>& signal_callback,
-    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) {
+    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) override {
     DoRegisterSignal1SignalHandler(signal_callback, &on_connected_callback);
   }
-  MOCK_METHOD2(DoRegisterSignal1SignalHandler,
-               void(const base::RepeatingCallback<void(const YetAnotherProto&,
-                                                       const std::tuple<int32_t, base::ScopedFD>&)>& /*signal_callback*/,
-                    dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
+  MOCK_METHOD(void,
+              DoRegisterSignal1SignalHandler,
+              (const base::RepeatingCallback<void(const YetAnotherProto&,
+                                                  const std::tuple<int32_t, base::ScopedFD>&)>& /*signal_callback*/,
+               dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
+
   void RegisterSignal2SignalHandler(
     const base::RepeatingCallback<void(const std::vector<uint8_t>&,
                                        int32_t)>& signal_callback,
-    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) {
+    dbus::ObjectProxy::OnConnectedCallback on_connected_callback) override {
     DoRegisterSignal2SignalHandler(signal_callback, &on_connected_callback);
   }
-  MOCK_METHOD2(DoRegisterSignal2SignalHandler,
-               void(const base::RepeatingCallback<void(const std::vector<uint8_t>&,
-                                                       int32_t)>& /*signal_callback*/,
-                    dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
+  MOCK_METHOD(void,
+              DoRegisterSignal2SignalHandler,
+              (const base::RepeatingCallback<void(const std::vector<uint8_t>&,
+                                                  int32_t)>& /*signal_callback*/,
+               dbus::ObjectProxy::OnConnectedCallback* /*on_connected_callback*/));
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -836,15 +898,24 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_CONST_METHOD0(readonly_property, const brillo::VariantDictionary&());
-  MOCK_CONST_METHOD0(is_readonly_property_valid, bool());
-  MOCK_CONST_METHOD0(writable_property, const brillo::VariantDictionary&());
-  MOCK_CONST_METHOD0(is_writable_property_valid, bool());
-  MOCK_METHOD2(set_writable_property, void(const brillo::VariantDictionary&, base::OnceCallback<void(bool)>));
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
-  MOCK_METHOD1(InitializeProperties,
-               void(const base::RepeatingCallback<void(EmptyInterfaceProxyInterface*, const std::string&)>&));
+  MOCK_METHOD(const brillo::VariantDictionary&, readonly_property, (), (const, override));
+  MOCK_METHOD(bool, is_readonly_property_valid, (), (const, override));
+
+  MOCK_METHOD(const brillo::VariantDictionary&, writable_property, (), (const, override));
+  MOCK_METHOD(bool, is_writable_property_valid, (), (const, override));
+  MOCK_METHOD(void,
+              set_writable_property,
+              (const brillo::VariantDictionary&, base::OnceCallback<void(bool)>),
+              (override));
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
+
+  MOCK_METHOD(void,
+              InitializeProperties,
+              ((const base::RepeatingCallback<void(EmptyInterfaceProxyInterface*,
+                                                   const std::string&)>&)),
+              (override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H
@@ -912,15 +983,24 @@
   EmptyInterfaceProxyMock(const EmptyInterfaceProxyMock&) = delete;
   EmptyInterfaceProxyMock& operator=(const EmptyInterfaceProxyMock&) = delete;
 
-  MOCK_CONST_METHOD0(readonly_property, const brillo::VariantDictionary&());
-  MOCK_CONST_METHOD0(is_readonly_property_valid, bool());
-  MOCK_CONST_METHOD0(writable_property, const brillo::VariantDictionary&());
-  MOCK_CONST_METHOD0(is_writable_property_valid, bool());
-  MOCK_METHOD2(set_writable_property, void(const brillo::VariantDictionary&, base::OnceCallback<void(bool)>));
-  MOCK_CONST_METHOD0(GetObjectPath, const dbus::ObjectPath&());
-  MOCK_CONST_METHOD0(GetObjectProxy, dbus::ObjectProxy*());
-  MOCK_METHOD1(SetPropertyChangedCallback,
-               void(const base::RepeatingCallback<void(EmptyInterfaceProxyInterface*, const std::string&)>&));
+  MOCK_METHOD(const brillo::VariantDictionary&, readonly_property, (), (const, override));
+  MOCK_METHOD(bool, is_readonly_property_valid, (), (const, override));
+
+  MOCK_METHOD(const brillo::VariantDictionary&, writable_property, (), (const, override));
+  MOCK_METHOD(bool, is_writable_property_valid, (), (const, override));
+  MOCK_METHOD(void,
+              set_writable_property,
+              (const brillo::VariantDictionary&, base::OnceCallback<void(bool)>),
+              (override));
+
+  MOCK_METHOD(const dbus::ObjectPath&, GetObjectPath, (), (const, override));
+  MOCK_METHOD(dbus::ObjectProxy*, GetObjectProxy, (), (const, override));
+
+  MOCK_METHOD(void,
+              SetPropertyChangedCallback,
+              ((const base::RepeatingCallback<void(EmptyInterfaceProxyInterface*,
+                                                   const std::string&)>&)),
+              (override));
 };
 
 #endif  // ____CHROMEOS_DBUS_BINDING___TMP_MOCK_H