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