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

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

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes mistake in previous patch set. Created 4 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
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/installer_state.h" 5 #include "chrome/installer/util/installer_state.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <fstream> 10 #include <fstream>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 EXPECT_TRUE(chrome_key.Valid()); 371 EXPECT_TRUE(chrome_key.Valid());
372 if (chrome_key.Valid()) { 372 if (chrome_key.Valid()) {
373 chrome_key.WriteValue(google_update::kRegVersionField, 373 chrome_key.WriteValue(google_update::kRegVersionField,
374 base::UTF8ToWide( 374 base::UTF8ToWide(
375 current_version.GetString()).c_str()); 375 current_version.GetString()).c_str());
376 machine_state.Initialize(); 376 machine_state.Initialize();
377 // TODO(tommi): Also test for when there exists a new_chrome.exe. 377 // TODO(tommi): Also test for when there exists a new_chrome.exe.
378 Version found_version(*installer_state.GetCurrentVersion(machine_state)); 378 Version found_version(*installer_state.GetCurrentVersion(machine_state));
379 EXPECT_TRUE(found_version.IsValid()); 379 EXPECT_TRUE(found_version.IsValid());
380 if (found_version.IsValid()) 380 if (found_version.IsValid())
381 EXPECT_TRUE(current_version.Equals(found_version)); 381 EXPECT_EQ(current_version, found_version);
382 } 382 }
383 } 383 }
384 } 384 }
385 385
386 TEST_F(InstallerStateTest, InstallerResult) { 386 TEST_F(InstallerStateTest, InstallerResult) {
387 const bool system_level = true; 387 const bool system_level = true;
388 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 388 HKEY root = system_level ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
389 389
390 RegKey key; 390 RegKey key;
391 std::wstring launch_cmd = L"hey diddle diddle"; 391 std::wstring launch_cmd = L"hey diddle diddle";
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 Version* InstallerStateCriticalVersionTest::opv_version_ = NULL; 738 Version* InstallerStateCriticalVersionTest::opv_version_ = NULL;
739 Version* InstallerStateCriticalVersionTest::middle_version_ = NULL; 739 Version* InstallerStateCriticalVersionTest::middle_version_ = NULL;
740 Version* InstallerStateCriticalVersionTest::pv_version_ = NULL; 740 Version* InstallerStateCriticalVersionTest::pv_version_ = NULL;
741 Version* InstallerStateCriticalVersionTest::high_version_ = NULL; 741 Version* InstallerStateCriticalVersionTest::high_version_ = NULL;
742 742
743 // Test the case where the critical version is less than the currently-running 743 // Test the case where the critical version is less than the currently-running
744 // Chrome. The critical version is ignored since it doesn't apply. 744 // Chrome. The critical version is ignored since it doesn't apply.
745 TEST_F(InstallerStateCriticalVersionTest, CriticalBeforeOpv) { 745 TEST_F(InstallerStateCriticalVersionTest, CriticalBeforeOpv) {
746 MockInstallerState& installer_state(Initialize(low_version_)); 746 MockInstallerState& installer_state(Initialize(low_version_));
747 747
748 EXPECT_TRUE(installer_state.critical_update_version().Equals(*low_version_)); 748 EXPECT_EQ(installer_state.critical_update_version(), *low_version_);
749 // Unable to determine the installed version, so assume critical update. 749 // Unable to determine the installed version, so assume critical update.
750 EXPECT_TRUE( 750 EXPECT_TRUE(
751 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 751 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
752 // Installed version is past the critical update. 752 // Installed version is past the critical update.
753 EXPECT_FALSE( 753 EXPECT_FALSE(
754 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 754 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
755 .IsValid()); 755 .IsValid());
756 // Installed version is past the critical update. 756 // Installed version is past the critical update.
757 EXPECT_FALSE( 757 EXPECT_FALSE(
758 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 758 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
759 .IsValid()); 759 .IsValid());
760 } 760 }
761 761
762 // Test the case where the critical version is equal to the currently-running 762 // Test the case where the critical version is equal to the currently-running
763 // Chrome. The critical version is ignored since it doesn't apply. 763 // Chrome. The critical version is ignored since it doesn't apply.
764 TEST_F(InstallerStateCriticalVersionTest, CriticalEqualsOpv) { 764 TEST_F(InstallerStateCriticalVersionTest, CriticalEqualsOpv) {
765 MockInstallerState& installer_state(Initialize(opv_version_)); 765 MockInstallerState& installer_state(Initialize(opv_version_));
766 766
767 EXPECT_TRUE(installer_state.critical_update_version().Equals(*opv_version_)); 767 EXPECT_EQ(installer_state.critical_update_version(), *opv_version_);
768 // Unable to determine the installed version, so assume critical update. 768 // Unable to determine the installed version, so assume critical update.
769 EXPECT_TRUE( 769 EXPECT_TRUE(
770 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 770 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
771 // Installed version equals the critical update. 771 // Installed version equals the critical update.
772 EXPECT_FALSE( 772 EXPECT_FALSE(
773 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 773 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
774 .IsValid()); 774 .IsValid());
775 // Installed version equals the critical update. 775 // Installed version equals the critical update.
776 EXPECT_FALSE( 776 EXPECT_FALSE(
777 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 777 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
778 .IsValid()); 778 .IsValid());
779 } 779 }
780 780
781 // Test the case where the critical version is between the currently-running 781 // Test the case where the critical version is between the currently-running
782 // Chrome and the to-be-installed Chrome. 782 // Chrome and the to-be-installed Chrome.
783 TEST_F(InstallerStateCriticalVersionTest, CriticalBetweenOpvAndPv) { 783 TEST_F(InstallerStateCriticalVersionTest, CriticalBetweenOpvAndPv) {
784 MockInstallerState& installer_state(Initialize(middle_version_)); 784 MockInstallerState& installer_state(Initialize(middle_version_));
785 785
786 EXPECT_TRUE(installer_state.critical_update_version().Equals( 786 EXPECT_EQ(installer_state.critical_update_version(), *middle_version_);
787 *middle_version_));
788 // Unable to determine the installed version, so assume critical update. 787 // Unable to determine the installed version, so assume critical update.
789 EXPECT_TRUE( 788 EXPECT_TRUE(
790 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 789 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
791 // Installed version before the critical update. 790 // Installed version before the critical update.
792 EXPECT_TRUE( 791 EXPECT_TRUE(
793 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 792 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
794 .IsValid()); 793 .IsValid());
795 // Installed version is past the critical update. 794 // Installed version is past the critical update.
796 EXPECT_FALSE( 795 EXPECT_FALSE(
797 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 796 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
798 .IsValid()); 797 .IsValid());
799 } 798 }
800 799
801 // Test the case where the critical version is the same as the to-be-installed 800 // Test the case where the critical version is the same as the to-be-installed
802 // Chrome. 801 // Chrome.
803 TEST_F(InstallerStateCriticalVersionTest, CriticalEqualsPv) { 802 TEST_F(InstallerStateCriticalVersionTest, CriticalEqualsPv) {
804 MockInstallerState& installer_state(Initialize(pv_version_)); 803 MockInstallerState& installer_state(Initialize(pv_version_));
805 804
806 EXPECT_TRUE(installer_state.critical_update_version().Equals( 805 EXPECT_EQ(installer_state.critical_update_version(), *pv_version_);
807 *pv_version_));
808 // Unable to determine the installed version, so assume critical update. 806 // Unable to determine the installed version, so assume critical update.
809 EXPECT_TRUE( 807 EXPECT_TRUE(
810 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 808 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
811 // Installed version before the critical update. 809 // Installed version before the critical update.
812 EXPECT_TRUE( 810 EXPECT_TRUE(
813 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 811 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
814 .IsValid()); 812 .IsValid());
815 // Installed version equals the critical update. 813 // Installed version equals the critical update.
816 EXPECT_FALSE( 814 EXPECT_FALSE(
817 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 815 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
818 .IsValid()); 816 .IsValid());
819 } 817 }
820 818
821 // Test the case where the critical version is greater than the to-be-installed 819 // Test the case where the critical version is greater than the to-be-installed
822 // Chrome. 820 // Chrome.
823 TEST_F(InstallerStateCriticalVersionTest, CriticalAfterPv) { 821 TEST_F(InstallerStateCriticalVersionTest, CriticalAfterPv) {
824 MockInstallerState& installer_state(Initialize(high_version_)); 822 MockInstallerState& installer_state(Initialize(high_version_));
825 823
826 EXPECT_TRUE(installer_state.critical_update_version().Equals( 824 EXPECT_EQ(installer_state.critical_update_version(), *high_version_);
827 *high_version_));
828 // Critical update newer than the new version. 825 // Critical update newer than the new version.
829 EXPECT_FALSE( 826 EXPECT_FALSE(
830 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); 827 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid());
831 EXPECT_FALSE( 828 EXPECT_FALSE(
832 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) 829 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_)
833 .IsValid()); 830 .IsValid());
834 EXPECT_FALSE( 831 EXPECT_FALSE(
835 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) 832 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_)
836 .IsValid()); 833 .IsValid());
837 } 834 }
OLDNEW
« no previous file with comments | « chrome/installer/util/google_update_settings_unittest.cc ('k') | chrome/installer/util/product_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698