| 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/files/scoped_temp_dir.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 class ConnectorSettingsTest : public testing::Test { | 50 class ConnectorSettingsTest : public testing::Test { |
| 51 protected: | 51 protected: |
| 52 virtual void SetUp() OVERRIDE { | 52 virtual void SetUp() OVERRIDE { |
| 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 53 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 54 message_loop_proxy_ = base::MessageLoopProxy::current(); | 54 message_loop_proxy_ = base::MessageLoopProxy::current(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 ServiceProcessPrefs* CreateTestFile(const char* json) { | 57 ServiceProcessPrefs* CreateTestFile(const char* json) { |
| 58 base::FilePath file_name = temp_dir_.path().AppendASCII("file.txt"); | 58 base::FilePath file_name = temp_dir_.path().AppendASCII("file.txt"); |
| 59 file_util::Delete(file_name, false); | 59 base::Delete(file_name, false); |
| 60 if (json) { | 60 if (json) { |
| 61 std::string content = json; | 61 std::string content = json; |
| 62 std::replace(content.begin(), content.end(), '\'', '"'); | 62 std::replace(content.begin(), content.end(), '\'', '"'); |
| 63 file_util::WriteFile(file_name, content.c_str(), content.size()); | 63 file_util::WriteFile(file_name, content.c_str(), content.size()); |
| 64 } | 64 } |
| 65 ServiceProcessPrefs* prefs = | 65 ServiceProcessPrefs* prefs = |
| 66 new ServiceProcessPrefs(file_name, message_loop_proxy_.get()); | 66 new ServiceProcessPrefs(file_name, message_loop_proxy_.get()); |
| 67 prefs->ReadPrefs(); | 67 prefs->ReadPrefs(); |
| 68 return prefs; | 68 return prefs; |
| 69 } | 69 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 settings.SetXmppPingTimeoutSec(256); | 143 settings.SetXmppPingTimeoutSec(256); |
| 144 EXPECT_TRUE(settings.xmpp_ping_enabled()); | 144 EXPECT_TRUE(settings.xmpp_ping_enabled()); |
| 145 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), 256); | 145 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), 256); |
| 146 | 146 |
| 147 // Set invalid settings, and check correct defaults. | 147 // Set invalid settings, and check correct defaults. |
| 148 settings.SetXmppPingTimeoutSec(1); | 148 settings.SetXmppPingTimeoutSec(1); |
| 149 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), kMinimumXmppPingTimeoutSecs); | 149 EXPECT_EQ(settings.xmpp_ping_timeout_sec(), kMinimumXmppPingTimeoutSecs); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace cloud_print | 152 } // namespace cloud_print |
| OLD | NEW |