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

Unified Diff: chrome/browser/local_discovery/privetv3_session_unittest.cc

Issue 383023002: Partial setup flow with unittest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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: chrome/browser/local_discovery/privetv3_session_unittest.cc
diff --git a/chrome/browser/local_discovery/privetv3_session_unittest.cc b/chrome/browser/local_discovery/privetv3_session_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31291c31f3d2aad7d376da80701511ff582124d1
--- /dev/null
+++ b/chrome/browser/local_discovery/privetv3_session_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright 2014 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 "chrome/browser/local_discovery/privetv3_session.h"
+
+#include "chrome/browser/local_discovery/privet_http.h"
+#include "net/url_request/test_url_fetcher_factory.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace local_discovery {
+
+namespace {
+
+using testing::InvokeWithoutArgs;
+using testing::StrictMock;
+using testing::_;
+
+class MockDelegate : public PrivetV3Session::Delegate {
+ public:
+ MOCK_METHOD1(OnSetupConfirmationNeeded, void(const std::string&));
+ MOCK_METHOD0(OnSessionEstablished, void());
+ MOCK_METHOD0(OnCannotEstablishSession, void());
+};
+
+class PrivetV3SessionTest : public testing::Test {
+ public:
+ PrivetV3SessionTest()
+ : session_(scoped_ptr<PrivetHTTPClient>(), &delegate_) {}
+
+ virtual ~PrivetV3SessionTest() {}
+
+ protected:
+ virtual void SetUp() OVERRIDE {
+ EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(0);
+ EXPECT_CALL(delegate_, OnSessionEstablished()).Times(0);
+ EXPECT_CALL(delegate_, OnCannotEstablishSession()).Times(0);
+ }
+
+ StrictMock<MockDelegate> delegate_;
+ PrivetV3Session session_;
+};
+
+TEST_F(PrivetV3SessionTest, NotConfirmed) {
+ EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(1);
+ session_.Start();
+}
+
+TEST_F(PrivetV3SessionTest, Confirmed) {
+ EXPECT_CALL(delegate_, OnSessionEstablished()).Times(1);
+ EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(1).WillOnce(
+ InvokeWithoutArgs(&session_, &PrivetV3Session::ConfirmCode));
+ session_.Start();
+}
+
+} // namespace
+
+} // namespace local_discovery
« no previous file with comments | « chrome/browser/local_discovery/privetv3_session.cc ('k') | chrome/browser/local_discovery/privetv3_setup_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698