Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: extensions/browser/api/cast_channel/logger_unittest.cc

Issue 580923002: Ignore uninteresting events when recording the last errors to report (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/cast_channel/logger_unittest.cc
diff --git a/extensions/browser/api/cast_channel/logger_unittest.cc b/extensions/browser/api/cast_channel/logger_unittest.cc
index 3d1f964e42f585adfdee67fd8543fa8d0639dd2c..d7e14a3834d1d9ff2cca38b87d5fa357ec452f91 100644
--- a/extensions/browser/api/cast_channel/logger_unittest.cc
+++ b/extensions/browser/api/cast_channel/logger_unittest.cc
@@ -6,6 +6,7 @@
#include "extensions/browser/api/cast_channel/cast_auth_util.h"
#include "extensions/browser/api/cast_channel/logger.h"
#include "extensions/browser/api/cast_channel/logger_util.h"
+#include "net/base/net_errors.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/zlib/zlib.h"
@@ -182,6 +183,37 @@ TEST_F(CastChannelLoggerTest, BasicLogging) {
}
}
+TEST_F(CastChannelLoggerTest, UninterestingEventsIgnored) {
+ logger_->LogSocketEventWithRv(1, EventType::CAST_SOCKET_CREATED, net::OK);
+ // CAST_SOCKET_CREATED is interesting.
+ LastErrors last_errors = logger_->GetLastErrors(1);
+ EXPECT_EQ(last_errors.event_type, proto::CAST_SOCKET_CREATED);
+ EXPECT_EQ(last_errors.net_return_value, net::OK);
+
+ // These four events and net return value are not interesting, and are not
+ // reported in last_errors.
+ clock_->Advance(base::TimeDelta::FromMicroseconds(1));
+ logger_->LogSocketEventWithRv(1,
+ EventType::READY_STATE_CHANGED,
+ net::ERR_IO_PENDING);
+ clock_->Advance(base::TimeDelta::FromMicroseconds(1));
+ logger_->LogSocketEvent(1, EventType::ERROR_STATE_CHANGED);
+ clock_->Advance(base::TimeDelta::FromMicroseconds(1));
+ logger_->LogSocketEvent(1, EventType::NOTIFY_ON_MESSAGE);
+ clock_->Advance(base::TimeDelta::FromMicroseconds(1));
+ logger_->LogSocketEvent(1, EventType::NOTIFY_ON_ERROR);
+ last_errors = logger_->GetLastErrors(1);
+ EXPECT_EQ(last_errors.event_type, proto::CAST_SOCKET_CREATED);
+ EXPECT_EQ(last_errors.net_return_value, net::OK);
+
+ // Log an interesting event again.
+ clock_->Advance(base::TimeDelta::FromMicroseconds(1));
+ logger_->LogSocketEventWithRv(1, EventType::CONNECT_FAILED, net::ERR_FAILED);
+ last_errors = logger_->GetLastErrors(1);
+ EXPECT_EQ(last_errors.event_type, proto::CONNECT_FAILED);
+ EXPECT_EQ(last_errors.net_return_value, net::ERR_FAILED);
+}
+
TEST_F(CastChannelLoggerTest, LogSocketReadWrite) {
logger_->LogSocketEventWithRv(1, EventType::SOCKET_READ, 50);
clock_->Advance(base::TimeDelta::FromMicroseconds(1));

Powered by Google App Engine
This is Rietveld 408576698