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

Unified Diff: google_apis/gcm/engine/connection_event_tracker_unittest.cc

Issue 2481873002: Added ClientEvent proto and structure for storing events in the factory. (Closed)
Patch Set: Added ConnectionEventTracker to manage all the events. Created 4 years 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: google_apis/gcm/engine/connection_event_tracker_unittest.cc
diff --git a/google_apis/gcm/engine/connection_event_tracker_unittest.cc b/google_apis/gcm/engine/connection_event_tracker_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bd64c1daf2415af35c0d5d5c816a44ecd7f4306d
--- /dev/null
+++ b/google_apis/gcm/engine/connection_event_tracker_unittest.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "google_apis/gcm/engine/connection_event_tracker.h"
+
+#include "google_apis/gcm/protocol/mcs.pb.h"
+#include "net/base/net_errors.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gcm {
Peter Beverloo 2016/12/02 15:19:13 micro nit: wrap in an inner anonymous namespace
harkness 2016/12/05 15:39:00 Done.
+
+class ConnectionEventTrackerTest : public testing::Test {
+ public:
+ ConnectionEventTrackerTest() {}
Peter Beverloo 2016/12/02 15:19:13 nit: I think you can just delete the constructor.
harkness 2016/12/05 15:39:00 Done.
+
+ ConnectionEventTracker* tracker() { return &tracker_; }
+
+ private:
+ ConnectionEventTracker tracker_;
+};
+
+TEST_F(ConnectionEventTrackerTest, SuccessfulAttempt) {
harkness 2016/12/01 10:34:34 I'm planning to add more tests to this when I add
+ tracker()->StartConnectionAttempt();
+ tracker()->ConnectionAttemptSucceeded();
+ tracker()->EndConnectionAttempt();
+
+ mcs_proto::LoginRequest request;
+ tracker()->WriteToLoginRequest(&request);
+
+ ASSERT_EQ(request.client_event().size(), 1);
+ for (const auto& event : request.client_event())
+ EXPECT_EQ(event.type(), mcs_proto::ClientEvent::SUCCESSFUL_CONNECTION);
+}
+
+} // namespace gcm

Powered by Google App Engine
This is Rietveld 408576698