Commit b696977a authored by Andrei Polushin's avatar Andrei Polushin Committed by Commit Bot

Make EXPECT_EQ_UNIQUE_ID() macro use names from its lexical scope.

The macro EXPECT_EQ_UNIQUE_ID() has been defined in a way that expects
variables with exact names `expected' and `actual' defined in a dynamic
scope, i.e. in the scope of C++ code that actually uses either
EXPECT_EQ_UNIQUE_ID() or EXPECT_FORM_FIELD_DATA_EQUALS() macros.

It seems the original intent was to use argument expressions passed to
EXPECT_FORM_FIELD_DATA_EQUALS(), not necessarily bound to exact names.

BUG=896689

Change-Id: I4f782afc1c8ab7c55b77ee111dcbbe64002a4d6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757823
Auto-Submit: Andrei Polushin <anpol@yandex-team.ru>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Commit-Queue: Dominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691079}
parent 414ba491
...@@ -103,9 +103,10 @@ struct FormFieldData { ...@@ -103,9 +103,10 @@ struct FormFieldData {
// TODO(crbug.com/896689): Expand the logic/application of this to other // TODO(crbug.com/896689): Expand the logic/application of this to other
// platforms and/or merge this concept with |unique_renderer_id|. // platforms and/or merge this concept with |unique_renderer_id|.
base::string16 unique_id; base::string16 unique_id;
#define EXPECT_EQ_UNIQUE_ID() EXPECT_EQ(expected.unique_id, actual.unique_id) #define EXPECT_EQ_UNIQUE_ID(expected, actual) \
EXPECT_EQ((expected).unique_id, (actual).unique_id)
#else #else
#define EXPECT_EQ_UNIQUE_ID() #define EXPECT_EQ_UNIQUE_ID(expected, actual)
#endif #endif
// The name by which autofill knows this field. This is generally either the // The name by which autofill knows this field. This is generally either the
...@@ -184,7 +185,7 @@ std::ostream& operator<<(std::ostream& os, const FormFieldData& field); ...@@ -184,7 +185,7 @@ std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
// |FormFieldData|s in test code. // |FormFieldData|s in test code.
#define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \ #define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
do { \ do { \
EXPECT_EQ_UNIQUE_ID(); \ EXPECT_EQ_UNIQUE_ID(expected, actual); \
EXPECT_EQ(expected.label, actual.label); \ EXPECT_EQ(expected.label, actual.label); \
EXPECT_EQ(expected.name, actual.name); \ EXPECT_EQ(expected.name, actual.name); \
EXPECT_EQ(expected.value, actual.value); \ EXPECT_EQ(expected.value, actual.value); \
......
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