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

Side by Side Diff: chrome/browser/chromeos/extensions/device_local_account_external_policy_loader_unittest.cc

Issue 974713002: kiosk: Ensure launching latest version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittest compile Created 5 years, 9 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h" 5 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const char kExtensionCRXSourceDir[] = "extensions"; 61 const char kExtensionCRXSourceDir[] = "extensions";
62 const char kExtensionCRXFile[] = "good.crx"; 62 const char kExtensionCRXFile[] = "good.crx";
63 const char kExtensionCRXVersion[] = "1.0.0.0"; 63 const char kExtensionCRXVersion[] = "1.0.0.0";
64 64
65 class MockExternalPolicyProviderVisitor 65 class MockExternalPolicyProviderVisitor
66 : public extensions::ExternalProviderInterface::VisitorInterface { 66 : public extensions::ExternalProviderInterface::VisitorInterface {
67 public: 67 public:
68 MockExternalPolicyProviderVisitor(); 68 MockExternalPolicyProviderVisitor();
69 virtual ~MockExternalPolicyProviderVisitor(); 69 virtual ~MockExternalPolicyProviderVisitor();
70 70
71 MOCK_METHOD6(OnExternalExtensionFileFound, 71 MOCK_METHOD7(OnExternalExtensionFileFound,
72 bool(const std::string&, 72 bool(const std::string&,
73 const base::Version*, 73 const base::Version*,
74 const base::FilePath&, 74 const base::FilePath&,
75 extensions::Manifest::Location, 75 extensions::Manifest::Location,
76 int, 76 int,
77 bool,
77 bool)); 78 bool));
78 MOCK_METHOD6(OnExternalExtensionUpdateUrlFound, 79 MOCK_METHOD6(OnExternalExtensionUpdateUrlFound,
79 bool(const std::string&, 80 bool(const std::string&,
80 const std::string&, 81 const std::string&,
81 const GURL&, 82 const GURL&,
82 extensions::Manifest::Location, 83 extensions::Manifest::Location,
83 int, 84 int,
84 bool)); 85 bool));
85 MOCK_METHOD1(OnExternalProviderReady, 86 MOCK_METHOD1(OnExternalProviderReady,
86 void(const extensions::ExternalProviderInterface* provider)); 87 void(const extensions::ExternalProviderInterface* provider));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 VerifyAndResetVisitorCallExpectations(); 159 VerifyAndResetVisitorCallExpectations();
159 } 160 }
160 161
161 void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() { 162 void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() {
162 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(NULL); 163 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext(NULL);
163 } 164 }
164 165
165 void DeviceLocalAccountExternalPolicyLoaderTest:: 166 void DeviceLocalAccountExternalPolicyLoaderTest::
166 VerifyAndResetVisitorCallExpectations() { 167 VerifyAndResetVisitorCallExpectations() {
167 Mock::VerifyAndClearExpectations(&visitor_); 168 Mock::VerifyAndClearExpectations(&visitor_);
168 EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _)) 169 EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
169 .Times(0); 170 .Times(0);
170 EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) 171 EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
171 .Times(0); 172 .Times(0);
172 EXPECT_CALL(visitor_, OnExternalProviderReady(_)) 173 EXPECT_CALL(visitor_, OnExternalProviderReady(_))
173 .Times(0); 174 .Times(0);
174 } 175 }
175 176
176 void DeviceLocalAccountExternalPolicyLoaderTest::SetForceInstallListPolicy() { 177 void DeviceLocalAccountExternalPolicyLoaderTest::SetForceInstallListPolicy() {
177 scoped_ptr<base::ListValue> forcelist(new base::ListValue); 178 scoped_ptr<base::ListValue> forcelist(new base::ListValue);
178 forcelist->AppendString("invalid"); 179 forcelist->AppendString("invalid");
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // file, served from the cache directory. 284 // file, served from the cache directory.
284 const base::FilePath cached_crx_path = cache_dir_.Append(base::StringPrintf( 285 const base::FilePath cached_crx_path = cache_dir_.Append(base::StringPrintf(
285 "%s-%s.crx", kExtensionId, kExtensionCRXVersion)); 286 "%s-%s.crx", kExtensionId, kExtensionCRXVersion));
286 base::RunLoop cache_run_loop; 287 base::RunLoop cache_run_loop;
287 EXPECT_CALL(visitor_, OnExternalExtensionFileFound( 288 EXPECT_CALL(visitor_, OnExternalExtensionFileFound(
288 kExtensionId, 289 kExtensionId,
289 _, 290 _,
290 cached_crx_path, 291 cached_crx_path,
291 extensions::Manifest::EXTERNAL_POLICY, 292 extensions::Manifest::EXTERNAL_POLICY,
292 _, 293 _,
294 _,
293 _)); 295 _));
294 EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get())) 296 EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get()))
295 .Times(1) 297 .Times(1)
296 .WillOnce(InvokeWithoutArgs(&cache_run_loop, &base::RunLoop::Quit)); 298 .WillOnce(InvokeWithoutArgs(&cache_run_loop, &base::RunLoop::Quit));
297 cache_run_loop.Run(); 299 cache_run_loop.Run();
298 VerifyAndResetVisitorCallExpectations(); 300 VerifyAndResetVisitorCallExpectations();
299 301
300 // Verify that the CRX file actually exists in the cache directory and its 302 // Verify that the CRX file actually exists in the cache directory and its
301 // contents matches the file returned to the downloader. 303 // contents matches the file returned to the downloader.
302 EXPECT_TRUE(base::ContentsEqual( 304 EXPECT_TRUE(base::ContentsEqual(
303 test_dir_.Append(kExtensionCRXSourceDir).Append(kExtensionCRXFile), 305 test_dir_.Append(kExtensionCRXSourceDir).Append(kExtensionCRXFile),
304 cached_crx_path)); 306 cached_crx_path));
305 307
306 // Stop the cache. Verify that the loader announces an empty extension list. 308 // Stop the cache. Verify that the loader announces an empty extension list.
307 EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get())) 309 EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get()))
308 .Times(1); 310 .Times(1);
309 base::RunLoop shutdown_run_loop; 311 base::RunLoop shutdown_run_loop;
310 loader_->StopCache(shutdown_run_loop.QuitClosure()); 312 loader_->StopCache(shutdown_run_loop.QuitClosure());
311 VerifyAndResetVisitorCallExpectations(); 313 VerifyAndResetVisitorCallExpectations();
312 314
313 // Spin the loop until the cache shutdown callback is invoked. Verify that at 315 // Spin the loop until the cache shutdown callback is invoked. Verify that at
314 // that point, no further file I/O tasks are pending. 316 // that point, no further file I/O tasks are pending.
315 shutdown_run_loop.Run(); 317 shutdown_run_loop.Run();
316 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting()); 318 EXPECT_TRUE(base::MessageLoop::current()->IsIdleForTesting());
317 } 319 }
318 320
319 } // namespace chromeos 321 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698