Chromium Code Reviews| 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 |