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 "chrome/service/cloud_print/connector_settings.h" | 5 #include "chrome/service/cloud_print/connector_settings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
12 #include "base/scoped_temp_dir.h" | |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/service/cloud_print/cloud_print_consts.h" | 14 #include "chrome/service/cloud_print/cloud_print_consts.h" |
15 #include "chrome/service/service_process_prefs.h" | 15 #include "chrome/service/service_process_prefs.h" |
16 | 16 |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 const char kServiceStateContent[] = | 20 const char kServiceStateContent[] = |
21 "{" | 21 "{" |
22 " 'cloud_print': {" | 22 " 'cloud_print': {" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 std::string content = json; | 56 std::string content = json; |
57 std::replace(content.begin(), content.end(), '\'', '"'); | 57 std::replace(content.begin(), content.end(), '\'', '"'); |
58 file_util::WriteFile(file_name, content.c_str(), content.size()); | 58 file_util::WriteFile(file_name, content.c_str(), content.size()); |
59 } | 59 } |
60 ServiceProcessPrefs* prefs = | 60 ServiceProcessPrefs* prefs = |
61 new ServiceProcessPrefs(file_name, message_loop_proxy_); | 61 new ServiceProcessPrefs(file_name, message_loop_proxy_); |
62 prefs->ReadPrefs(); | 62 prefs->ReadPrefs(); |
63 return prefs; | 63 return prefs; |
64 } | 64 } |
65 | 65 |
66 ScopedTempDir temp_dir_; | 66 base::ScopedTempDir temp_dir_; |
67 MessageLoop message_loop_; | 67 MessageLoop message_loop_; |
68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 68 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
69 }; | 69 }; |
70 | 70 |
71 TEST_F(ConnectorSettingsTest, InitFromEmpty) { | 71 TEST_F(ConnectorSettingsTest, InitFromEmpty) { |
72 const char* const kEmptyJSons[] = { | 72 const char* const kEmptyJSons[] = { |
73 NULL, | 73 NULL, |
74 "{}", | 74 "{}", |
75 "{'foo': []}", | 75 "{'foo': []}", |
76 "{'foo',,}", | 76 "{'foo',,}", |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Set and check valid settings. | 136 // Set and check valid settings. |
137 settings.set_xmpp_ping_enabled(true); | 137 settings.set_xmpp_ping_enabled(true); |
138 settings.SetXmppPingTimeoutSec(256); | 138 settings.SetXmppPingTimeoutSec(256); |
139 EXPECT_TRUE(settings.xmpp_ping_enabled()); | 139 EXPECT_TRUE(settings.xmpp_ping_enabled()); |
140 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), 256); | 140 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), 256); |
141 | 141 |
142 // Set invalid settings, and check correct defaults. | 142 // Set invalid settings, and check correct defaults. |
143 settings.SetXmppPingTimeoutSec(1); | 143 settings.SetXmppPingTimeoutSec(1); |
144 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), kMinimumXmppPingTimeoutSecs); | 144 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), kMinimumXmppPingTimeoutSecs); |
145 } | 145 } |
OLD | NEW |