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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/local_discovery/privetv3_session.h"
6
7 #include "chrome/browser/local_discovery/privet_http.h"
8 #include "net/url_request/test_url_fetcher_factory.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace local_discovery {
13
14 namespace {
15
16 using testing::InvokeWithoutArgs;
17 using testing::StrictMock;
18 using testing::_;
19
20 class MockDelegate : public PrivetV3Session::Delegate {
21 public:
22 MOCK_METHOD1(OnSetupConfirmationNeeded, void(const std::string&));
23 MOCK_METHOD0(OnSessionEstablished, void());
24 MOCK_METHOD0(OnCannotEstablishSession, void());
25 };
26
27 class PrivetV3SessionTest : public testing::Test {
28 public:
29 PrivetV3SessionTest()
30 : session_(scoped_ptr<PrivetHTTPClient>(), &delegate_) {}
31
32 virtual ~PrivetV3SessionTest() {}
33
34 protected:
35 virtual void SetUp() OVERRIDE {
36 EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(0);
37 EXPECT_CALL(delegate_, OnSessionEstablished()).Times(0);
38 EXPECT_CALL(delegate_, OnCannotEstablishSession()).Times(0);
39 }
40
41 StrictMock<MockDelegate> delegate_;
42 PrivetV3Session session_;
43 };
44
45 TEST_F(PrivetV3SessionTest, NotConfirmed) {
46 EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(1);
47 session_.Start();
48 }
49
50 TEST_F(PrivetV3SessionTest, Confirmed) {
51 EXPECT_CALL(delegate_, OnSessionEstablished()).Times(1);
52 EXPECT_CALL(delegate_, OnSetupConfirmationNeeded(_)).Times(1).WillOnce(
53 InvokeWithoutArgs(&session_, &PrivetV3Session::ConfirmCode));
54 session_.Start();
55 }
56
57 } // namespace
58
59 } // namespace local_discovery
OLDNEW
« 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