| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" |
| 7 #include "base/values.h" | 8 #include "base/values.h" |
| 8 #include "content/browser/media/webrtc_internals.h" | 9 #include "content/browser/media/webrtc_internals.h" |
| 9 #include "content/browser/media/webrtc_internals_ui_observer.h" | 10 #include "content/browser/media/webrtc_internals_ui_observer.h" |
| 10 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 static const std::string kContraints = "c"; | 18 static const std::string kContraints = "c"; |
| 18 static const std::string kRtcConfiguration = "r"; | 19 static const std::string kRtcConfiguration = "r"; |
| 19 static const std::string kUrl = "u"; | 20 static const std::string kUrl = "u"; |
| 20 | 21 |
| 21 class MockWebRtcInternalsProxy : public WebRTCInternalsUIObserver { | 22 class MockWebRtcInternalsProxy : public WebRTCInternalsUIObserver { |
| 22 public: | 23 public: |
| 23 void OnUpdate(const std::string& command, const base::Value* value) override { | 24 MockWebRtcInternalsProxy() : loop_(nullptr) {} |
| 24 command_ = command; | 25 explicit MockWebRtcInternalsProxy(base::RunLoop* loop) : loop_(loop) {} |
| 25 if (value) | |
| 26 value_.reset(value->DeepCopy()); | |
| 27 } | |
| 28 | 26 |
| 29 std::string command() { | 27 const std::string& command() const { |
| 30 return command_; | 28 return command_; |
| 31 } | 29 } |
| 32 | 30 |
| 33 base::Value* value() { | 31 base::Value* value() { |
| 34 return value_.get(); | 32 return value_.get(); |
| 35 } | 33 } |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 std::string command_; | 36 void OnUpdate(const std::string& command, const base::Value* value) override { |
| 39 scoped_ptr<base::Value> value_; | 37 command_ = command; |
| 38 value_.reset(value ? value->DeepCopy() : nullptr); |
| 39 if (loop_) |
| 40 loop_->Quit(); |
| 41 } |
| 42 |
| 43 std::string command_; |
| 44 scoped_ptr<base::Value> value_; |
| 45 base::RunLoop* loop_; |
| 40 }; | 46 }; |
| 41 | 47 |
| 48 // Derived class for testing only. Allows the tests to have their own instance |
| 49 // for testing and control the period for which WebRTCInternals will bulk up |
| 50 // updates (changes down from 500ms to 1ms). |
| 51 class WebRTCInternalsForTest : public NON_EXPORTED_BASE(WebRTCInternals) { |
| 52 public: |
| 53 WebRTCInternalsForTest() : WebRTCInternals(1) {} |
| 54 ~WebRTCInternalsForTest() override {} |
| 55 }; |
| 56 |
| 57 } // namespace |
| 58 |
| 42 class WebRtcInternalsTest : public testing::Test { | 59 class WebRtcInternalsTest : public testing::Test { |
| 43 public: | 60 public: |
| 44 WebRtcInternalsTest() : io_thread_(BrowserThread::UI, &io_loop_) { | 61 WebRtcInternalsTest() : io_thread_(BrowserThread::UI, &io_loop_) {} |
| 45 WebRTCInternals::GetInstance()->ResetForTesting(); | |
| 46 } | |
| 47 | 62 |
| 48 protected: | 63 protected: |
| 49 void VerifyString(const base::DictionaryValue* dict, | 64 void VerifyString(const base::DictionaryValue* dict, |
| 50 const std::string& key, | 65 const std::string& key, |
| 51 const std::string& expected) { | 66 const std::string& expected) { |
| 52 std::string actual; | 67 std::string actual; |
| 53 EXPECT_TRUE(dict->GetString(key, &actual)); | 68 EXPECT_TRUE(dict->GetString(key, &actual)); |
| 54 EXPECT_EQ(expected, actual); | 69 EXPECT_EQ(expected, actual); |
| 55 } | 70 } |
| 56 | 71 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 VerifyInt(dict, "pid", pid); | 98 VerifyInt(dict, "pid", pid); |
| 84 VerifyString(dict, "origin", origin); | 99 VerifyString(dict, "origin", origin); |
| 85 VerifyString(dict, "audio", audio); | 100 VerifyString(dict, "audio", audio); |
| 86 VerifyString(dict, "video", video); | 101 VerifyString(dict, "video", video); |
| 87 } | 102 } |
| 88 | 103 |
| 89 base::MessageLoop io_loop_; | 104 base::MessageLoop io_loop_; |
| 90 TestBrowserThread io_thread_; | 105 TestBrowserThread io_thread_; |
| 91 }; | 106 }; |
| 92 | 107 |
| 93 } // namespace | 108 TEST_F(WebRtcInternalsTest, AddRemoveObserver) { |
| 109 base::RunLoop loop; |
| 110 MockWebRtcInternalsProxy observer(&loop); |
| 111 WebRTCInternalsForTest webrtc_internals; |
| 112 webrtc_internals.AddObserver(&observer); |
| 94 | 113 |
| 95 TEST_F(WebRtcInternalsTest, AddRemoveObserver) { | 114 webrtc_internals.RemoveObserver(&observer); |
| 96 scoped_ptr<MockWebRtcInternalsProxy> observer( | 115 // The observer should not get notified of this activity. |
| 97 new MockWebRtcInternalsProxy()); | 116 webrtc_internals.OnAddPeerConnection( |
| 98 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | |
| 99 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | |
| 100 WebRTCInternals::GetInstance()->OnAddPeerConnection( | |
| 101 0, 3, 4, kUrl, kRtcConfiguration, kContraints); | 117 0, 3, 4, kUrl, kRtcConfiguration, kContraints); |
| 102 EXPECT_EQ("", observer->command()); | |
| 103 | 118 |
| 104 WebRTCInternals::GetInstance()->OnRemovePeerConnection(3, 4); | 119 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| 120 loop.QuitClosure(), |
| 121 base::TimeDelta::FromMilliseconds(5)); |
| 122 loop.Run(); |
| 123 |
| 124 EXPECT_EQ("", observer.command()); |
| 125 |
| 126 webrtc_internals.OnRemovePeerConnection(3, 4); |
| 105 } | 127 } |
| 106 | 128 |
| 107 TEST_F(WebRtcInternalsTest, SendAddPeerConnectionUpdate) { | 129 TEST_F(WebRtcInternalsTest, SendAddPeerConnectionUpdate) { |
| 108 scoped_ptr<MockWebRtcInternalsProxy> observer( | 130 base::RunLoop loop; |
| 109 new MockWebRtcInternalsProxy()); | 131 MockWebRtcInternalsProxy observer(&loop); |
| 110 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 132 WebRTCInternalsForTest webrtc_internals; |
| 111 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 133 webrtc_internals.AddObserver(&observer); |
| 134 webrtc_internals.OnAddPeerConnection( |
| 112 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 135 0, 1, 2, kUrl, kRtcConfiguration, kContraints); |
| 113 EXPECT_EQ("addPeerConnection", observer->command()); | 136 |
| 137 loop.Run(); |
| 138 |
| 139 ASSERT_EQ("addPeerConnection", observer.command()); |
| 114 | 140 |
| 115 base::DictionaryValue* dict = NULL; | 141 base::DictionaryValue* dict = NULL; |
| 116 EXPECT_TRUE(observer->value()->GetAsDictionary(&dict)); | 142 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 117 | 143 |
| 118 VerifyInt(dict, "pid", 1); | 144 VerifyInt(dict, "pid", 1); |
| 119 VerifyInt(dict, "lid", 2); | 145 VerifyInt(dict, "lid", 2); |
| 120 VerifyString(dict, "url", kUrl); | 146 VerifyString(dict, "url", kUrl); |
| 121 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); | 147 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); |
| 122 VerifyString(dict, "constraints", kContraints); | 148 VerifyString(dict, "constraints", kContraints); |
| 123 | 149 |
| 124 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | 150 webrtc_internals.RemoveObserver(&observer); |
| 125 WebRTCInternals::GetInstance()->OnRemovePeerConnection(1, 2); | 151 webrtc_internals.OnRemovePeerConnection(1, 2); |
| 126 } | 152 } |
| 127 | 153 |
| 128 TEST_F(WebRtcInternalsTest, SendRemovePeerConnectionUpdate) { | 154 TEST_F(WebRtcInternalsTest, SendRemovePeerConnectionUpdate) { |
| 129 scoped_ptr<MockWebRtcInternalsProxy> observer( | 155 base::RunLoop loop; |
| 130 new MockWebRtcInternalsProxy()); | 156 MockWebRtcInternalsProxy observer(&loop); |
| 131 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 157 WebRTCInternalsForTest webrtc_internals; |
| 132 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 158 webrtc_internals.AddObserver(&observer); |
| 159 webrtc_internals.OnAddPeerConnection( |
| 133 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 160 0, 1, 2, kUrl, kRtcConfiguration, kContraints); |
| 134 WebRTCInternals::GetInstance()->OnRemovePeerConnection(1, 2); | 161 webrtc_internals.OnRemovePeerConnection(1, 2); |
| 135 EXPECT_EQ("removePeerConnection", observer->command()); | 162 |
| 163 loop.Run(); |
| 164 |
| 165 ASSERT_EQ("removePeerConnection", observer.command()); |
| 136 | 166 |
| 137 base::DictionaryValue* dict = NULL; | 167 base::DictionaryValue* dict = NULL; |
| 138 EXPECT_TRUE(observer->value()->GetAsDictionary(&dict)); | 168 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 139 | 169 |
| 140 VerifyInt(dict, "pid", 1); | 170 VerifyInt(dict, "pid", 1); |
| 141 VerifyInt(dict, "lid", 2); | 171 VerifyInt(dict, "lid", 2); |
| 142 | 172 |
| 143 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | 173 webrtc_internals.RemoveObserver(&observer); |
| 144 } | 174 } |
| 145 | 175 |
| 146 TEST_F(WebRtcInternalsTest, SendUpdatePeerConnectionUpdate) { | 176 TEST_F(WebRtcInternalsTest, SendUpdatePeerConnectionUpdate) { |
| 147 scoped_ptr<MockWebRtcInternalsProxy> observer( | 177 base::RunLoop loop; |
| 148 new MockWebRtcInternalsProxy()); | 178 MockWebRtcInternalsProxy observer(&loop); |
| 149 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 179 WebRTCInternalsForTest webrtc_internals; |
| 150 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 180 webrtc_internals.AddObserver(&observer); |
| 181 webrtc_internals.OnAddPeerConnection( |
| 151 0, 1, 2, kUrl, kRtcConfiguration, kContraints); | 182 0, 1, 2, kUrl, kRtcConfiguration, kContraints); |
| 152 | 183 |
| 153 const std::string update_type = "fakeType"; | 184 const std::string update_type = "fakeType"; |
| 154 const std::string update_value = "fakeValue"; | 185 const std::string update_value = "fakeValue"; |
| 155 WebRTCInternals::GetInstance()->OnUpdatePeerConnection( | 186 webrtc_internals.OnUpdatePeerConnection( |
| 156 1, 2, update_type, update_value); | 187 1, 2, update_type, update_value); |
| 157 | 188 |
| 158 EXPECT_EQ("updatePeerConnection", observer->command()); | 189 loop.Run(); |
| 190 |
| 191 ASSERT_EQ("updatePeerConnection", observer.command()); |
| 159 | 192 |
| 160 base::DictionaryValue* dict = NULL; | 193 base::DictionaryValue* dict = NULL; |
| 161 EXPECT_TRUE(observer->value()->GetAsDictionary(&dict)); | 194 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 162 | 195 |
| 163 VerifyInt(dict, "pid", 1); | 196 VerifyInt(dict, "pid", 1); |
| 164 VerifyInt(dict, "lid", 2); | 197 VerifyInt(dict, "lid", 2); |
| 165 VerifyString(dict, "type", update_type); | 198 VerifyString(dict, "type", update_type); |
| 166 VerifyString(dict, "value", update_value); | 199 VerifyString(dict, "value", update_value); |
| 167 | 200 |
| 168 std::string time; | 201 std::string time; |
| 169 EXPECT_TRUE(dict->GetString("time", &time)); | 202 EXPECT_TRUE(dict->GetString("time", &time)); |
| 170 EXPECT_FALSE(time.empty()); | 203 EXPECT_FALSE(time.empty()); |
| 171 | 204 |
| 172 WebRTCInternals::GetInstance()->OnRemovePeerConnection(1, 2); | 205 webrtc_internals.OnRemovePeerConnection(1, 2); |
| 173 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | 206 webrtc_internals.RemoveObserver(&observer); |
| 174 } | 207 } |
| 175 | 208 |
| 176 TEST_F(WebRtcInternalsTest, AddGetUserMedia) { | 209 TEST_F(WebRtcInternalsTest, AddGetUserMedia) { |
| 177 scoped_ptr<MockWebRtcInternalsProxy> observer(new MockWebRtcInternalsProxy()); | 210 base::RunLoop loop; |
| 211 MockWebRtcInternalsProxy observer(&loop); |
| 212 WebRTCInternalsForTest webrtc_internals; |
| 178 | 213 |
| 179 // Add one observer before "getUserMedia". | 214 // Add one observer before "getUserMedia". |
| 180 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 215 webrtc_internals.AddObserver(&observer); |
| 181 | 216 |
| 182 const int rid = 1; | 217 const int rid = 1; |
| 183 const int pid = 2; | 218 const int pid = 2; |
| 184 const std::string audio_constraint = "aaa"; | 219 const std::string audio_constraint = "aaa"; |
| 185 const std::string video_constraint = "vvv"; | 220 const std::string video_constraint = "vvv"; |
| 186 WebRTCInternals::GetInstance()->OnGetUserMedia( | 221 webrtc_internals.OnGetUserMedia( |
| 187 rid, pid, kUrl, true, true, audio_constraint, video_constraint); | 222 rid, pid, kUrl, true, true, audio_constraint, video_constraint); |
| 188 | 223 |
| 189 EXPECT_EQ("addGetUserMedia", observer->command()); | 224 loop.Run(); |
| 225 |
| 226 ASSERT_EQ("addGetUserMedia", observer.command()); |
| 190 VerifyGetUserMediaData( | 227 VerifyGetUserMediaData( |
| 191 observer->value(), rid, pid, kUrl, audio_constraint, video_constraint); | 228 observer.value(), rid, pid, kUrl, audio_constraint, video_constraint); |
| 192 | 229 |
| 193 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | 230 webrtc_internals.RemoveObserver(&observer); |
| 194 } | 231 } |
| 195 | 232 |
| 196 TEST_F(WebRtcInternalsTest, SendAllUpdateWithGetUserMedia) { | 233 TEST_F(WebRtcInternalsTest, SendAllUpdateWithGetUserMedia) { |
| 197 const int rid = 1; | 234 const int rid = 1; |
| 198 const int pid = 2; | 235 const int pid = 2; |
| 199 const std::string audio_constraint = "aaa"; | 236 const std::string audio_constraint = "aaa"; |
| 200 const std::string video_constraint = "vvv"; | 237 const std::string video_constraint = "vvv"; |
| 201 WebRTCInternals::GetInstance()->OnGetUserMedia( | 238 WebRTCInternalsForTest webrtc_internals; |
| 239 webrtc_internals.OnGetUserMedia( |
| 202 rid, pid, kUrl, true, true, audio_constraint, video_constraint); | 240 rid, pid, kUrl, true, true, audio_constraint, video_constraint); |
| 203 | 241 |
| 204 scoped_ptr<MockWebRtcInternalsProxy> observer(new MockWebRtcInternalsProxy()); | 242 MockWebRtcInternalsProxy observer; |
| 205 // Add one observer after "getUserMedia". | 243 // Add one observer after "getUserMedia". |
| 206 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 244 webrtc_internals.AddObserver(&observer); |
| 207 WebRTCInternals::GetInstance()->UpdateObserver(observer.get()); | 245 webrtc_internals.UpdateObserver(&observer); |
| 208 | 246 |
| 209 EXPECT_EQ("addGetUserMedia", observer->command()); | 247 EXPECT_EQ("addGetUserMedia", observer.command()); |
| 210 VerifyGetUserMediaData( | 248 VerifyGetUserMediaData( |
| 211 observer->value(), rid, pid, kUrl, audio_constraint, video_constraint); | 249 observer.value(), rid, pid, kUrl, audio_constraint, video_constraint); |
| 212 | 250 |
| 213 WebRTCInternals::GetInstance()->RemoveObserver(observer.get()); | 251 webrtc_internals.RemoveObserver(&observer); |
| 214 } | 252 } |
| 215 | 253 |
| 216 TEST_F(WebRtcInternalsTest, SendAllUpdatesWithPeerConnectionUpdate) { | 254 TEST_F(WebRtcInternalsTest, SendAllUpdatesWithPeerConnectionUpdate) { |
| 217 const int rid = 0, pid = 1, lid = 2; | 255 const int rid = 0, pid = 1, lid = 2; |
| 218 const std::string update_type = "fakeType"; | 256 const std::string update_type = "fakeType"; |
| 219 const std::string update_value = "fakeValue"; | 257 const std::string update_value = "fakeValue"; |
| 220 | 258 |
| 221 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 259 WebRTCInternalsForTest webrtc_internals; |
| 260 |
| 261 webrtc_internals.OnAddPeerConnection( |
| 222 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); | 262 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); |
| 223 WebRTCInternals::GetInstance()->OnUpdatePeerConnection( | 263 webrtc_internals.OnUpdatePeerConnection( |
| 224 pid, lid, update_type, update_value); | 264 pid, lid, update_type, update_value); |
| 225 | 265 |
| 226 scoped_ptr<MockWebRtcInternalsProxy> observer(new MockWebRtcInternalsProxy()); | 266 MockWebRtcInternalsProxy observer; |
| 227 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 267 webrtc_internals.AddObserver(&observer); |
| 228 | 268 |
| 229 WebRTCInternals::GetInstance()->UpdateObserver(observer.get()); | 269 webrtc_internals.UpdateObserver(&observer); |
| 230 | 270 |
| 231 EXPECT_EQ("updateAllPeerConnections", observer->command()); | 271 EXPECT_EQ("updateAllPeerConnections", observer.command()); |
| 272 ASSERT_TRUE(observer.value()); |
| 232 | 273 |
| 233 base::ListValue* list = NULL; | 274 base::ListValue* list = NULL; |
| 234 EXPECT_TRUE(observer->value()->GetAsList(&list)); | 275 EXPECT_TRUE(observer.value()->GetAsList(&list)); |
| 235 EXPECT_EQ(1U, list->GetSize()); | 276 EXPECT_EQ(1U, list->GetSize()); |
| 236 | 277 |
| 237 base::DictionaryValue* dict = NULL; | 278 base::DictionaryValue* dict = NULL; |
| 238 EXPECT_TRUE((*list->begin())->GetAsDictionary(&dict)); | 279 EXPECT_TRUE((*list->begin())->GetAsDictionary(&dict)); |
| 239 | 280 |
| 240 VerifyInt(dict, "rid", rid); | 281 VerifyInt(dict, "rid", rid); |
| 241 VerifyInt(dict, "pid", pid); | 282 VerifyInt(dict, "pid", pid); |
| 242 VerifyInt(dict, "lid", lid); | 283 VerifyInt(dict, "lid", lid); |
| 243 VerifyString(dict, "url", kUrl); | 284 VerifyString(dict, "url", kUrl); |
| 244 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); | 285 VerifyString(dict, "rtcConfiguration", kRtcConfiguration); |
| 245 VerifyString(dict, "constraints", kContraints); | 286 VerifyString(dict, "constraints", kContraints); |
| 246 | 287 |
| 247 base::ListValue* log = NULL; | 288 base::ListValue* log = NULL; |
| 248 EXPECT_TRUE(dict->GetList("log", &log)); | 289 EXPECT_TRUE(dict->GetList("log", &log)); |
| 249 EXPECT_EQ(1U, log->GetSize()); | 290 EXPECT_EQ(1U, log->GetSize()); |
| 250 | 291 |
| 251 EXPECT_TRUE((*log->begin())->GetAsDictionary(&dict)); | 292 EXPECT_TRUE((*log->begin())->GetAsDictionary(&dict)); |
| 252 VerifyString(dict, "type", update_type); | 293 VerifyString(dict, "type", update_type); |
| 253 VerifyString(dict, "value", update_value); | 294 VerifyString(dict, "value", update_value); |
| 254 std::string time; | 295 std::string time; |
| 255 EXPECT_TRUE(dict->GetString("time", &time)); | 296 EXPECT_TRUE(dict->GetString("time", &time)); |
| 256 EXPECT_FALSE(time.empty()); | 297 EXPECT_FALSE(time.empty()); |
| 257 } | 298 } |
| 258 | 299 |
| 259 TEST_F(WebRtcInternalsTest, OnAddStats) { | 300 TEST_F(WebRtcInternalsTest, OnAddStats) { |
| 260 const int rid = 0, pid = 1, lid = 2; | 301 const int rid = 0, pid = 1, lid = 2; |
| 261 scoped_ptr<MockWebRtcInternalsProxy> observer(new MockWebRtcInternalsProxy()); | 302 base::RunLoop loop; |
| 262 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 303 MockWebRtcInternalsProxy observer(&loop); |
| 263 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 304 WebRTCInternalsForTest webrtc_internals; |
| 305 webrtc_internals.AddObserver(&observer); |
| 306 webrtc_internals.OnAddPeerConnection( |
| 264 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); | 307 rid, pid, lid, kUrl, kRtcConfiguration, kContraints); |
| 265 | 308 |
| 266 base::ListValue list; | 309 base::ListValue list; |
| 267 list.AppendString("xxx"); | 310 list.AppendString("xxx"); |
| 268 list.AppendString("yyy"); | 311 list.AppendString("yyy"); |
| 269 WebRTCInternals::GetInstance()->OnAddStats(pid, lid, list); | 312 webrtc_internals.OnAddStats(pid, lid, list); |
| 270 | 313 |
| 271 EXPECT_EQ("addStats", observer->command()); | 314 loop.Run(); |
| 315 |
| 316 EXPECT_EQ("addStats", observer.command()); |
| 317 ASSERT_TRUE(observer.value()); |
| 318 |
| 272 base::DictionaryValue* dict = NULL; | 319 base::DictionaryValue* dict = NULL; |
| 273 EXPECT_TRUE(observer->value()->GetAsDictionary(&dict)); | 320 EXPECT_TRUE(observer.value()->GetAsDictionary(&dict)); |
| 274 | 321 |
| 275 VerifyInt(dict, "pid", pid); | 322 VerifyInt(dict, "pid", pid); |
| 276 VerifyInt(dict, "lid", lid); | 323 VerifyInt(dict, "lid", lid); |
| 277 VerifyList(dict, "reports", list); | 324 VerifyList(dict, "reports", list); |
| 278 } | 325 } |
| 279 | 326 |
| 280 TEST_F(WebRtcInternalsTest, AudioDebugRecordingsFileSelectionCanceled) { | 327 TEST_F(WebRtcInternalsTest, AudioDebugRecordingsFileSelectionCanceled) { |
| 281 scoped_ptr<MockWebRtcInternalsProxy> observer(new MockWebRtcInternalsProxy()); | 328 base::RunLoop loop; |
| 282 WebRTCInternals::GetInstance()->AddObserver(observer.get()); | 329 |
| 283 WebRTCInternals::GetInstance()->FileSelectionCanceled(NULL); | 330 MockWebRtcInternalsProxy observer(&loop); |
| 284 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer->command()); | 331 WebRTCInternalsForTest webrtc_internals; |
| 285 EXPECT_EQ(NULL, observer->value()); | 332 |
| 333 webrtc_internals.AddObserver(&observer); |
| 334 webrtc_internals.FileSelectionCanceled(nullptr); |
| 335 |
| 336 loop.Run(); |
| 337 |
| 338 EXPECT_EQ("audioDebugRecordingsFileSelectionCancelled", observer.command()); |
| 339 EXPECT_EQ(nullptr, observer.value()); |
| 286 } | 340 } |
| 287 | 341 |
| 288 } // namespace content | 342 } // namespace content |
| OLD | NEW |