| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/media/webrtc/webrtc_browsertest_base.h" | 5 #include "chrome/browser/media/webrtc/webrtc_browsertest_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 EXPECT_TRUE(item->IsType(base::Value::Type::STRING)); | 144 EXPECT_TRUE(item->IsType(base::Value::Type::STRING)); |
| 145 std::string item_str; | 145 std::string item_str; |
| 146 EXPECT_TRUE(item->GetAsString(&item_str)); | 146 EXPECT_TRUE(item->GetAsString(&item_str)); |
| 147 vector.push_back(std::move(item_str)); | 147 vector.push_back(std::move(item_str)); |
| 148 } | 148 } |
| 149 return vector; | 149 return vector; |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 WebRtcTestBase::TrackEvent::TrackEvent(const std::string& track_id) |
| 155 : track_id(track_id) {} |
| 156 |
| 157 WebRtcTestBase::TrackEvent::TrackEvent(const TrackEvent&) = default; |
| 158 |
| 159 WebRtcTestBase::TrackEvent::~TrackEvent() = default; |
| 160 |
| 154 WebRtcTestBase::WebRtcTestBase(): detect_errors_in_javascript_(false) { | 161 WebRtcTestBase::WebRtcTestBase(): detect_errors_in_javascript_(false) { |
| 155 // The handler gets set for each test method, but that's fine since this | 162 // The handler gets set for each test method, but that's fine since this |
| 156 // set operation is idempotent. | 163 // set operation is idempotent. |
| 157 logging::SetLogMessageHandler(&JavascriptErrorDetectingLogHandler); | 164 logging::SetLogMessageHandler(&JavascriptErrorDetectingLogHandler); |
| 158 hit_javascript_errors_.Get() = false; | 165 hit_javascript_errors_.Get() = false; |
| 159 | 166 |
| 160 EnablePixelOutput(); | 167 EnablePixelOutput(); |
| 161 } | 168 } |
| 162 | 169 |
| 163 WebRtcTestBase::~WebRtcTestBase() { | 170 WebRtcTestBase::~WebRtcTestBase() { |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 691 |
| 685 size_t WebRtcTestBase::GetNegotiationNeededCount( | 692 size_t WebRtcTestBase::GetNegotiationNeededCount( |
| 686 content::WebContents* tab) const { | 693 content::WebContents* tab) const { |
| 687 std::string result = ExecuteJavascript("getNegotiationNeededCount()", tab); | 694 std::string result = ExecuteJavascript("getNegotiationNeededCount()", tab); |
| 688 EXPECT_TRUE(base::StartsWith(result, "ok-negotiation-count-is-", | 695 EXPECT_TRUE(base::StartsWith(result, "ok-negotiation-count-is-", |
| 689 base::CompareCase::SENSITIVE)); | 696 base::CompareCase::SENSITIVE)); |
| 690 size_t count = 0; | 697 size_t count = 0; |
| 691 EXPECT_TRUE(base::StringToSizeT(result.substr(24), &count)); | 698 EXPECT_TRUE(base::StringToSizeT(result.substr(24), &count)); |
| 692 return count; | 699 return count; |
| 693 } | 700 } |
| 701 |
| 702 void WebRtcTestBase::SetupOnTrackListener(content::WebContents* tab) const { |
| 703 EXPECT_EQ("ok-ontrack-wired", |
| 704 ExecuteJavascript("setupOnTrackListener()", tab)); |
| 705 } |
| 706 |
| 707 std::vector<WebRtcTestBase::TrackEvent> WebRtcTestBase::GetTrackEvents( |
| 708 content::WebContents* tab) const { |
| 709 std::string result = ExecuteJavascript("getOnTrackEvents()", tab); |
| 710 EXPECT_TRUE(base::StartsWith(result, "ok-", base::CompareCase::SENSITIVE)); |
| 711 std::vector<std::string> tokens = base::SplitString( |
| 712 result.substr(3), " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
| 713 std::vector<TrackEvent> events; |
| 714 for (size_t i = 0; i < tokens.size(); ++i) { |
| 715 if (tokens[i] == "RTCTrackEvent") { |
| 716 DCHECK_LT(i + 1, tokens.size()); |
| 717 events.push_back(TrackEvent(tokens[++i])); |
| 718 } else { |
| 719 DCHECK(!events.empty()); |
| 720 events[events.size() - 1].stream_ids.push_back(tokens[i]); |
| 721 } |
| 722 } |
| 723 return events; |
| 724 } |
| OLD | NEW |