OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/gaia/google_service_auth_error.h" | 5 #include "google_apis/gaia/google_service_auth_error.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <string> | 8 #include <string> |
8 | 9 |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/test/values_test_util.h" | 10 #include "base/test/values_test_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 using base::ExpectDictStringValue; | 17 using base::ExpectDictStringValue; |
18 | 18 |
19 class GoogleServiceAuthErrorTest : public testing::Test {}; | 19 class GoogleServiceAuthErrorTest : public testing::Test {}; |
20 | 20 |
21 void TestSimpleState(GoogleServiceAuthError::State state) { | 21 void TestSimpleState(GoogleServiceAuthError::State state) { |
22 GoogleServiceAuthError error(state); | 22 GoogleServiceAuthError error(state); |
23 scoped_ptr<base::DictionaryValue> value(error.ToValue()); | 23 std::unique_ptr<base::DictionaryValue> value(error.ToValue()); |
24 EXPECT_EQ(1u, value->size()); | 24 EXPECT_EQ(1u, value->size()); |
25 std::string state_str; | 25 std::string state_str; |
26 EXPECT_TRUE(value->GetString("state", &state_str)); | 26 EXPECT_TRUE(value->GetString("state", &state_str)); |
27 EXPECT_FALSE(state_str.empty()); | 27 EXPECT_FALSE(state_str.empty()); |
28 EXPECT_NE("CONNECTION_FAILED", state_str); | 28 EXPECT_NE("CONNECTION_FAILED", state_str); |
29 EXPECT_NE("CAPTCHA_REQUIRED", state_str); | 29 EXPECT_NE("CAPTCHA_REQUIRED", state_str); |
30 } | 30 } |
31 | 31 |
32 TEST_F(GoogleServiceAuthErrorTest, SimpleToValue) { | 32 TEST_F(GoogleServiceAuthErrorTest, SimpleToValue) { |
33 for (int i = GoogleServiceAuthError::NONE; | 33 for (int i = GoogleServiceAuthError::NONE; |
34 i <= GoogleServiceAuthError::USER_NOT_SIGNED_UP; ++i) { | 34 i <= GoogleServiceAuthError::USER_NOT_SIGNED_UP; ++i) { |
35 TestSimpleState(static_cast<GoogleServiceAuthError::State>(i)); | 35 TestSimpleState(static_cast<GoogleServiceAuthError::State>(i)); |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 TEST_F(GoogleServiceAuthErrorTest, None) { | 39 TEST_F(GoogleServiceAuthErrorTest, None) { |
40 GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone()); | 40 GoogleServiceAuthError error(GoogleServiceAuthError::AuthErrorNone()); |
41 scoped_ptr<base::DictionaryValue> value(error.ToValue()); | 41 std::unique_ptr<base::DictionaryValue> value(error.ToValue()); |
42 EXPECT_EQ(1u, value->size()); | 42 EXPECT_EQ(1u, value->size()); |
43 ExpectDictStringValue("NONE", *value, "state"); | 43 ExpectDictStringValue("NONE", *value, "state"); |
44 } | 44 } |
45 | 45 |
46 TEST_F(GoogleServiceAuthErrorTest, ConnectionFailed) { | 46 TEST_F(GoogleServiceAuthErrorTest, ConnectionFailed) { |
47 GoogleServiceAuthError error( | 47 GoogleServiceAuthError error( |
48 GoogleServiceAuthError::FromConnectionError(net::OK)); | 48 GoogleServiceAuthError::FromConnectionError(net::OK)); |
49 scoped_ptr<base::DictionaryValue> value(error.ToValue()); | 49 std::unique_ptr<base::DictionaryValue> value(error.ToValue()); |
50 EXPECT_EQ(2u, value->size()); | 50 EXPECT_EQ(2u, value->size()); |
51 ExpectDictStringValue("CONNECTION_FAILED", *value, "state"); | 51 ExpectDictStringValue("CONNECTION_FAILED", *value, "state"); |
52 ExpectDictStringValue("net::OK", *value, "networkError"); | 52 ExpectDictStringValue("net::OK", *value, "networkError"); |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
OLD | NEW |