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

Side by Side Diff: chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 " }" 86 " }"
87 "}"; 87 "}";
88 88
89 const char kTestPolicy2JSON[] = "{\"Another\":\"turn_it_off\"}"; 89 const char kTestPolicy2JSON[] = "{\"Another\":\"turn_it_off\"}";
90 90
91 #if defined(OS_CHROMEOS) 91 #if defined(OS_CHROMEOS)
92 92
93 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF01234567"; 93 const char kSanitizedUsername[] = "0123456789ABCDEF0123456789ABCDEF01234567";
94 94
95 ACTION(GetSanitizedUsername) { 95 ACTION(GetSanitizedUsername) {
96 MessageLoop::current()->PostTask( 96 base::MessageLoop::current()->PostTask(
97 FROM_HERE, 97 FROM_HERE,
98 base::Bind(arg1, chromeos::DBUS_METHOD_CALL_SUCCESS, kSanitizedUsername)); 98 base::Bind(arg1, chromeos::DBUS_METHOD_CALL_SUCCESS, kSanitizedUsername));
99 } 99 }
100 100
101 ACTION_P(RetrieveUserPolicy, storage) { 101 ACTION_P(RetrieveUserPolicy, storage) {
102 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, *storage)); 102 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, *storage));
103 } 103 }
104 104
105 ACTION_P2(StoreUserPolicy, storage, user_policy_key_file) { 105 ACTION_P2(StoreUserPolicy, storage, user_policy_key_file) {
106 // The session_manager stores a copy of the policy key at 106 // The session_manager stores a copy of the policy key at
107 // /var/run/user_policy/$hash/policy.pub. Simulate that behavior here, so 107 // /var/run/user_policy/$hash/policy.pub. Simulate that behavior here, so
108 // that the policy signature can be validated. 108 // that the policy signature can be validated.
109 em::PolicyFetchResponse policy; 109 em::PolicyFetchResponse policy;
110 ASSERT_TRUE(policy.ParseFromString(arg0)); 110 ASSERT_TRUE(policy.ParseFromString(arg0));
111 if (policy.has_new_public_key()) { 111 if (policy.has_new_public_key()) {
112 ASSERT_TRUE(file_util::CreateDirectory(user_policy_key_file.DirName())); 112 ASSERT_TRUE(file_util::CreateDirectory(user_policy_key_file.DirName()));
113 int result = file_util::WriteFile( 113 int result = file_util::WriteFile(
114 user_policy_key_file, 114 user_policy_key_file,
115 policy.new_public_key().data(), 115 policy.new_public_key().data(),
116 policy.new_public_key().size()); 116 policy.new_public_key().size());
117 ASSERT_EQ(static_cast<int>(policy.new_public_key().size()), result); 117 ASSERT_EQ(static_cast<int>(policy.new_public_key().size()), result);
118 } 118 }
119 119
120 *storage = arg0; 120 *storage = arg0;
121 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg1, true)); 121 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg1, true));
122 } 122 }
123 123
124 #else 124 #else
125 125
126 const char kTestUser[] = "user@example.com"; 126 const char kTestUser[] = "user@example.com";
127 127
128 #endif // OS_CHROMEOS 128 #endif // OS_CHROMEOS
129 129
130 } // namespace 130 } // namespace
131 131
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ASSERT_EQ(kTestExtension2, extension2->id()); 319 ASSERT_EQ(kTestExtension2, extension2->id());
320 320
321 // This extension only sends the 'policy' signal once it receives the policy, 321 // This extension only sends the 'policy' signal once it receives the policy,
322 // and after verifying it has the expected value. Otherwise it sends 'fail'. 322 // and after verifying it has the expected value. Otherwise it sends 'fail'.
323 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); 323 EXPECT_TRUE(result_listener.WaitUntilSatisfied());
324 } 324 }
325 325
326 #endif // OS_CHROMEOS 326 #endif // OS_CHROMEOS
327 327
328 } // namespace policy 328 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698