OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" | 5 #include "chrome/browser/printing/cloud_print/privet_confirm_api_flow.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using testing::StrictMock; | 13 using testing::StrictMock; |
14 using testing::_; | 14 using testing::_; |
15 | 15 |
16 namespace local_discovery { | 16 namespace cloud_print { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kSampleConfirmResponse[] = "{" | 20 const char kSampleConfirmResponse[] = "{" |
21 " \"success\": true" | 21 " \"success\": true" |
22 "}"; | 22 "}"; |
23 | 23 |
24 const char kFailedConfirmResponse[] = "{" | 24 const char kFailedConfirmResponse[] = "{" |
25 " \"success\": false" | 25 " \"success\": false" |
26 "}"; | 26 "}"; |
(...skipping 17 matching lines...) Expand all Loading... |
44 TEST(PrivetConfirmApiFlowTest, Parsing) { | 44 TEST(PrivetConfirmApiFlowTest, Parsing) { |
45 StrictMock<MockDelegate> delegate; | 45 StrictMock<MockDelegate> delegate; |
46 PrivetConfirmApiCallFlow confirmation( | 46 PrivetConfirmApiCallFlow confirmation( |
47 "123", base::Bind(&MockDelegate::Callback, base::Unretained(&delegate))); | 47 "123", base::Bind(&MockDelegate::Callback, base::Unretained(&delegate))); |
48 EXPECT_CALL(delegate, Callback(GCDApiFlow::SUCCESS)).Times(1); | 48 EXPECT_CALL(delegate, Callback(GCDApiFlow::SUCCESS)).Times(1); |
49 | 49 |
50 scoped_ptr<base::Value> value = | 50 scoped_ptr<base::Value> value = |
51 base::JSONReader::Read(kSampleConfirmResponse); | 51 base::JSONReader::Read(kSampleConfirmResponse); |
52 const base::DictionaryValue* dictionary = NULL; | 52 const base::DictionaryValue* dictionary = NULL; |
53 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); | 53 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); |
54 confirmation.OnGCDAPIFlowComplete(*dictionary); | 54 confirmation.OnGCDApiFlowComplete(*dictionary); |
55 | 55 |
56 EXPECT_CALL(delegate, Callback(GCDApiFlow::ERROR_FROM_SERVER)).Times(1); | 56 EXPECT_CALL(delegate, Callback(GCDApiFlow::ERROR_FROM_SERVER)).Times(1); |
57 | 57 |
58 value = base::JSONReader::Read(kFailedConfirmResponse); | 58 value = base::JSONReader::Read(kFailedConfirmResponse); |
59 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); | 59 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); |
60 confirmation.OnGCDAPIFlowComplete(*dictionary); | 60 confirmation.OnGCDApiFlowComplete(*dictionary); |
61 } | 61 } |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 } // namespace local_discovery | 65 } // namespace cloud_print |
OLD | NEW |