From 7ab5f801dd8d6bc018b59d41877f44ec4ab19d15 Mon Sep 17 00:00:00 2001 From: phoglund Date: Wed, 24 Jun 2015 01:11:46 -0700 Subject: [PATCH] Adding an equals method for KeyValuePair for easier testing. With this we can write stuff like assertThat(result.mandatory, hasItem(new KeyValuePair("minWidth", "1280"))); The above will currently fail because the object falls back to ==. BUG=None Review URL: https://codereview.webrtc.org/1193883006 Cr-Commit-Position: refs/heads/master@{#9494} --- .../java/src/org/webrtc/MediaConstraints.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/talk/app/webrtc/java/src/org/webrtc/MediaConstraints.java b/talk/app/webrtc/java/src/org/webrtc/MediaConstraints.java index f2b0aedb2a..730df3553d 100644 --- a/talk/app/webrtc/java/src/org/webrtc/MediaConstraints.java +++ b/talk/app/webrtc/java/src/org/webrtc/MediaConstraints.java @@ -56,8 +56,24 @@ public class MediaConstraints { public String toString() { return key + ": " + value; } - } + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (other == null || getClass() != other.getClass()) { + return false; + } + KeyValuePair that = (KeyValuePair)other; + return key.equals(that.key) && value.equals(that.value); + } + + @Override + public int hashCode() { + return key.hashCode() + value.hashCode(); + } + } public final List mandatory; public final List optional;