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/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 " ]," | 34 " ]," |
35 " 'print_system_settings': {" | 35 " 'print_system_settings': {" |
36 " 'delete_on_enum_fail' : true" | 36 " 'delete_on_enum_fail' : true" |
37 " }" | 37 " }" |
38 " }" | 38 " }" |
39 "}"; | 39 "}"; |
40 | 40 |
41 | 41 |
42 class ConnectorSettingsTest : public testing::Test { | 42 class ConnectorSettingsTest : public testing::Test { |
43 protected: | 43 protected: |
44 virtual void SetUp() { | 44 virtual void SetUp() OVERRIDE { |
45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 45 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
46 message_loop_proxy_ = base::MessageLoopProxy::current(); | 46 message_loop_proxy_ = base::MessageLoopProxy::current(); |
47 } | 47 } |
48 | 48 |
49 ServiceProcessPrefs* CreateTestFile(const char* json) { | 49 ServiceProcessPrefs* CreateTestFile(const char* json) { |
50 FilePath file_name = temp_dir_.path().AppendASCII("file.txt"); | 50 FilePath file_name = temp_dir_.path().AppendASCII("file.txt"); |
51 file_util::Delete(file_name, false); | 51 file_util::Delete(file_name, false); |
52 if (json) { | 52 if (json) { |
53 std::string content = json; | 53 std::string content = json; |
54 std::replace(content.begin(), content.end(), '\'', '"'); | 54 std::replace(content.begin(), content.end(), '\'', '"'); |
55 file_util::WriteFile(file_name, content.c_str(), content.size()); | 55 file_util::WriteFile(file_name, content.c_str(), content.size()); |
56 } | 56 } |
57 ServiceProcessPrefs* prefs = | 57 ServiceProcessPrefs* prefs = |
58 new ServiceProcessPrefs(file_name, message_loop_proxy_.get()); | 58 new ServiceProcessPrefs(file_name, message_loop_proxy_); |
59 prefs->ReadPrefs(); | 59 prefs->ReadPrefs(); |
60 return prefs; | 60 return prefs; |
61 } | 61 } |
62 | 62 |
63 ScopedTempDir temp_dir_; | 63 ScopedTempDir temp_dir_; |
64 MessageLoop message_loop_; | 64 MessageLoop message_loop_; |
65 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 65 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
66 }; | 66 }; |
67 | 67 |
68 TEST_F(ConnectorSettingsTest, InitFromEmpty) { | 68 TEST_F(ConnectorSettingsTest, InitFromEmpty) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 EXPECT_EQ(settings1.server_url(), settings2.server_url()); | 112 EXPECT_EQ(settings1.server_url(), settings2.server_url()); |
113 EXPECT_EQ(settings1.proxy_id(), settings2.proxy_id()); | 113 EXPECT_EQ(settings1.proxy_id(), settings2.proxy_id()); |
114 EXPECT_EQ(settings1.delete_on_enum_fail(), settings2.delete_on_enum_fail()); | 114 EXPECT_EQ(settings1.delete_on_enum_fail(), settings2.delete_on_enum_fail()); |
115 EXPECT_EQ(settings1.print_system_settings()->size(), | 115 EXPECT_EQ(settings1.print_system_settings()->size(), |
116 settings2.print_system_settings()->size()); | 116 settings2.print_system_settings()->size()); |
117 EXPECT_EQ(settings1.connect_new_printers(), settings2.connect_new_printers()); | 117 EXPECT_EQ(settings1.connect_new_printers(), settings2.connect_new_printers()); |
118 EXPECT_TRUE(settings2.IsPrinterBlacklisted("prn1")); | 118 EXPECT_TRUE(settings2.IsPrinterBlacklisted("prn1")); |
119 } | 119 } |
120 | 120 |
OLD | NEW |