Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/service/cloud_print/connector_settings_unittest.cc

Issue 10966052: Added options to disable specific printers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/service/cloud_print/connector_settings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/scoped_temp_dir.h" 12 #include "base/scoped_temp_dir.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/service/service_process_prefs.h" 14 #include "chrome/service/service_process_prefs.h"
15 15
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 const char kServiceStateContent[] = 19 const char kServiceStateContent[] =
20 "{" 20 "{"
21 " 'cloud_print': {" 21 " 'cloud_print': {"
22 " 'auth_token': 'token'," 22 " 'auth_token': 'token',"
23 " 'email': 'user@gmail.com'," 23 " 'email': 'user@gmail.com',"
24 " 'enabled': true," 24 " 'enabled': true,"
25 " 'proxy_id': 'PROXY'," 25 " 'proxy_id': 'PROXY',"
26 " 'robot_email': '123@cloudprint.googleusercontent.com'," 26 " 'robot_email': '123@cloudprint.googleusercontent.com',"
27 " 'robot_refresh_token': '123'," 27 " 'robot_refresh_token': '123',"
28 " 'service_url': 'http://cp.google.com'," 28 " 'service_url': 'http://cp.google.com',"
29 " 'xmpp_auth_token': 'xmp token'," 29 " 'xmpp_auth_token': 'xmp token',"
30 " 'connect_new_printers': false,"
31 " 'printer_blacklist': ["
32 " 'prn1',"
33 " 'prn2'"
34 " ],"
30 " 'print_system_settings': {" 35 " 'print_system_settings': {"
31 " 'delete_on_enum_fail' : true" 36 " 'delete_on_enum_fail' : true"
32 " }" 37 " }"
33 " }" 38 " }"
34 "}"; 39 "}";
35 40
36 41
37 class ConnectorSettingsTest : public testing::Test { 42 class ConnectorSettingsTest : public testing::Test {
38 protected: 43 protected:
39 virtual void SetUp() { 44 virtual void SetUp() {
(...skipping 30 matching lines...) Expand all
70 for (size_t i = 0; i < arraysize(kEmptyJSons); ++i) { 75 for (size_t i = 0; i < arraysize(kEmptyJSons); ++i) {
71 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kEmptyJSons[i])); 76 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kEmptyJSons[i]));
72 ConnectorSettings settings; 77 ConnectorSettings settings;
73 settings.InitFrom(prefs.get()); 78 settings.InitFrom(prefs.get());
74 79
75 EXPECT_EQ("https://www.google.com/cloudprint", 80 EXPECT_EQ("https://www.google.com/cloudprint",
76 settings.server_url().spec()); 81 settings.server_url().spec());
77 EXPECT_FALSE(settings.proxy_id().empty()); 82 EXPECT_FALSE(settings.proxy_id().empty());
78 EXPECT_FALSE(settings.delete_on_enum_fail()); 83 EXPECT_FALSE(settings.delete_on_enum_fail());
79 EXPECT_EQ(NULL, settings.print_system_settings()); 84 EXPECT_EQ(NULL, settings.print_system_settings());
85 EXPECT_TRUE(settings.connect_new_printers());
86 EXPECT_FALSE(settings.IsPrinterBlacklisted("prn1"));
80 } 87 }
81 } 88 }
82 89
83 TEST_F(ConnectorSettingsTest, InitFromFile) { 90 TEST_F(ConnectorSettingsTest, InitFromFile) {
84 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kServiceStateContent)); 91 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kServiceStateContent));
85 ConnectorSettings settings; 92 ConnectorSettings settings;
86 settings.InitFrom(prefs.get()); 93 settings.InitFrom(prefs.get());
87 EXPECT_EQ("http://cp.google.com/", settings.server_url().spec()); 94 EXPECT_EQ("http://cp.google.com/", settings.server_url().spec());
88 EXPECT_EQ("PROXY", settings.proxy_id()); 95 EXPECT_EQ("PROXY", settings.proxy_id());
89 EXPECT_FALSE(settings.proxy_id().empty()); 96 EXPECT_FALSE(settings.proxy_id().empty());
90 EXPECT_TRUE(settings.delete_on_enum_fail()); 97 EXPECT_TRUE(settings.delete_on_enum_fail());
91 EXPECT_TRUE(settings.print_system_settings()); 98 EXPECT_TRUE(settings.print_system_settings());
99 EXPECT_FALSE(settings.connect_new_printers());
100 EXPECT_FALSE(settings.IsPrinterBlacklisted("prn0"));
101 EXPECT_TRUE(settings.IsPrinterBlacklisted("prn1"));
92 } 102 }
93 103
94 TEST_F(ConnectorSettingsTest, CopyFrom) { 104 TEST_F(ConnectorSettingsTest, CopyFrom) {
95 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kServiceStateContent)); 105 scoped_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kServiceStateContent));
96 ConnectorSettings settings1; 106 ConnectorSettings settings1;
97 settings1.InitFrom(prefs.get()); 107 settings1.InitFrom(prefs.get());
98 108
99 ConnectorSettings settings2; 109 ConnectorSettings settings2;
100 settings2.CopyFrom(settings1); 110 settings2.CopyFrom(settings1);
101 111
102 EXPECT_EQ(settings1.server_url(), settings2.server_url()); 112 EXPECT_EQ(settings1.server_url(), settings2.server_url());
103 EXPECT_EQ(settings1.proxy_id(), settings2.proxy_id()); 113 EXPECT_EQ(settings1.proxy_id(), settings2.proxy_id());
104 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());
105 EXPECT_EQ(settings1.print_system_settings()->size(), 115 EXPECT_EQ(settings1.print_system_settings()->size(),
106 settings2.print_system_settings()->size()); 116 settings2.print_system_settings()->size());
117 EXPECT_EQ(settings1.connect_new_printers(), settings2.connect_new_printers());
118 EXPECT_TRUE(settings2.IsPrinterBlacklisted("prn1"));
107 } 119 }
108 120
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/connector_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698