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

Side by Side Diff: chrome/installer/util/install_util_unittest.cc

Issue 2476573004: Use InstallDetails in installer_util. (Closed)
Patch Set: sync to position 451835 Created 3 years, 10 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
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/run_all_unittests.cc » ('j') | 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/installer/util/install_util.h" 5 #include "chrome/installer/util/install_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 MAX_PATH); 362 MAX_PATH);
363 ASSERT_NE(static_cast<DWORD>(0), short_len); 363 ASSERT_NE(static_cast<DWORD>(0), short_len);
364 ASSERT_GT(static_cast<DWORD>(MAX_PATH), short_len); 364 ASSERT_GT(static_cast<DWORD>(MAX_PATH), short_len);
365 short_expect.resize(short_len); 365 short_expect.resize(short_len);
366 ASSERT_FALSE(base::FilePath::CompareEqualIgnoreCase(expect.value(), 366 ASSERT_FALSE(base::FilePath::CompareEqualIgnoreCase(expect.value(),
367 short_expect)); 367 short_expect));
368 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate( 368 EXPECT_TRUE(InstallUtil::ProgramCompare(expect).Evaluate(
369 L"\"" + short_expect + L"\"")); 369 L"\"" + short_expect + L"\""));
370 } 370 }
371 371
372 // Win64 Chrome is always installed in the 32-bit Program Files directory. Test
373 // that IsPerUserInstall returns false for an arbitrary path with
374 // DIR_PROGRAM_FILESX86 as a suffix but not DIR_PROGRAM_FILES when the two are
375 // unrelated.
376 TEST_F(InstallUtilTest, IsPerUserInstall) {
377 InstallUtil::ResetIsPerUserInstallForTest();
378
379 #if defined(_WIN64)
380 const int kChromeProgramFilesKey = base::DIR_PROGRAM_FILESX86;
381 #else
382 const int kChromeProgramFilesKey = base::DIR_PROGRAM_FILES;
383 #endif
384 base::ScopedPathOverride program_files_override(kChromeProgramFilesKey);
385 base::FilePath some_exe;
386 ASSERT_TRUE(PathService::Get(kChromeProgramFilesKey, &some_exe));
387 some_exe = some_exe.AppendASCII("Company")
388 .AppendASCII("Product")
389 .AppendASCII("product.exe");
390 EXPECT_FALSE(InstallUtil::IsPerUserInstall(some_exe));
391 InstallUtil::ResetIsPerUserInstallForTest();
392
393 #if defined(_WIN64)
394 const int kOtherProgramFilesKey = base::DIR_PROGRAM_FILES;
395 base::ScopedPathOverride other_program_files_override(kOtherProgramFilesKey);
396 ASSERT_TRUE(PathService::Get(kOtherProgramFilesKey, &some_exe));
397 some_exe = some_exe.AppendASCII("Company")
398 .AppendASCII("Product")
399 .AppendASCII("product.exe");
400 EXPECT_TRUE(InstallUtil::IsPerUserInstall(some_exe));
401 InstallUtil::ResetIsPerUserInstallForTest();
402 #endif // defined(_WIN64)
403 }
404
405 TEST_F(InstallUtilTest, AddDowngradeVersion) { 372 TEST_F(InstallUtilTest, AddDowngradeVersion) {
406 TestBrowserDistribution dist; 373 TestBrowserDistribution dist;
407 bool system_install = true; 374 bool system_install = true;
408 RegKey(HKEY_LOCAL_MACHINE, dist.GetStateKey().c_str(), 375 RegKey(HKEY_LOCAL_MACHINE, dist.GetStateKey().c_str(),
409 KEY_SET_VALUE | KEY_WOW64_32KEY); 376 KEY_SET_VALUE | KEY_WOW64_32KEY);
410 std::unique_ptr<WorkItemList> list; 377 std::unique_ptr<WorkItemList> list;
411 378
412 base::Version current_version("1.1.1.1"); 379 base::Version current_version("1.1.1.1");
413 base::Version higer_new_version("1.1.1.2"); 380 base::Version higer_new_version("1.1.1.2");
414 base::Version lower_new_version_1("1.1.1.0"); 381 base::Version lower_new_version_1("1.1.1.0");
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 ASSERT_TRUE(list->Do()); 464 ASSERT_TRUE(list->Do());
498 EXPECT_EQ(current_version, 465 EXPECT_EQ(current_version,
499 InstallUtil::GetDowngradeVersion(system_install, &dist)); 466 InstallUtil::GetDowngradeVersion(system_install, &dist));
500 list.reset(WorkItem::CreateWorkItemList()); 467 list.reset(WorkItem::CreateWorkItemList());
501 InstallUtil::AddUpdateDowngradeVersionItem( 468 InstallUtil::AddUpdateDowngradeVersionItem(
502 system_install, nullptr, lower_new_version_1, &dist, list.get()); 469 system_install, nullptr, lower_new_version_1, &dist, list.get());
503 ASSERT_TRUE(list->Do()); 470 ASSERT_TRUE(list->Do());
504 ASSERT_FALSE( 471 ASSERT_FALSE(
505 InstallUtil::GetDowngradeVersion(system_install, &dist).IsValid()); 472 InstallUtil::GetDowngradeVersion(system_install, &dist).IsValid());
506 } 473 }
OLDNEW
« no previous file with comments | « chrome/installer/util/install_util.cc ('k') | chrome/installer/util/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698