OLD | NEW |
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 // A test application for the RLZ library. | 5 // A test application for the RLZ library. |
6 // | 6 // |
7 // These tests should not be executed on the build server: | 7 // These tests should not be executed on the build server: |
8 // - They assert for the failed cases. | 8 // - They assert for the failed cases. |
9 // - They modify machine state (registry). | 9 // - They modify machine state (registry). |
10 // | 10 // |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 EXPECT_FALSE(rlz_lib::GetProductEventsAsCgi(rlz_lib::TOOLBAR_NOTIFIER, | 781 EXPECT_FALSE(rlz_lib::GetProductEventsAsCgi(rlz_lib::TOOLBAR_NOTIFIER, |
782 value, 50)); | 782 value, 50)); |
783 EXPECT_STREQ("", value); | 783 EXPECT_STREQ("", value); |
784 } | 784 } |
785 | 785 |
786 EXPECT_TRUE(rlz_lib::GetProductEventsAsCgi(rlz_lib::TOOLBAR_NOTIFIER, | 786 EXPECT_TRUE(rlz_lib::GetProductEventsAsCgi(rlz_lib::TOOLBAR_NOTIFIER, |
787 value, 50)); | 787 value, 50)); |
788 EXPECT_STREQ("events=I7S", value); | 788 EXPECT_STREQ("events=I7S", value); |
789 } | 789 } |
790 | 790 |
791 #if defined(OS_MACOSX) | 791 #if defined(OS_POSIX) |
792 class ReadonlyRlzDirectoryTest : public RlzLibTestNoMachineState { | 792 class ReadonlyRlzDirectoryTest : public RlzLibTestNoMachineState { |
793 protected: | 793 protected: |
794 virtual void SetUp() OVERRIDE; | 794 virtual void SetUp() OVERRIDE; |
795 }; | 795 }; |
796 | 796 |
797 void ReadonlyRlzDirectoryTest::SetUp() { | 797 void ReadonlyRlzDirectoryTest::SetUp() { |
798 RlzLibTestNoMachineState::SetUp(); | 798 RlzLibTestNoMachineState::SetUp(); |
799 // Make the rlz directory non-writeable. | 799 // Make the rlz directory non-writeable. |
800 int chmod_result = chmod(temp_dir_.path().value().c_str(), 0500); | 800 int chmod_result = chmod(temp_dir_.path().value().c_str(), 0500); |
801 ASSERT_EQ(0, chmod_result); | 801 ASSERT_EQ(0, chmod_result); |
802 | |
803 } | 802 } |
804 | 803 |
805 TEST_F(ReadonlyRlzDirectoryTest, WriteFails) { | 804 TEST_F(ReadonlyRlzDirectoryTest, WriteFails) { |
806 // The rlz test runner runs every test twice: Once normally, and once with | 805 // The rlz test runner runs every test twice: Once normally, and once with |
807 // a SupplementaryBranding on the stack. In the latter case, the rlz lock | 806 // a SupplementaryBranding on the stack. In the latter case, the rlz lock |
808 // has already been acquired before the rlz directory got changed to | 807 // has already been acquired before the rlz directory got changed to |
809 // read-only, which makes this test pointless. So run it only in the first | 808 // read-only, which makes this test pointless. So run it only in the first |
810 // pass. | 809 // pass. |
811 if (!rlz_lib::SupplementaryBranding::GetBrand().empty()) | 810 if (!rlz_lib::SupplementaryBranding::GetBrand().empty()) |
812 return; | 811 return; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 for (size_t i = 0; i < pids.size(); ++i) { | 865 for (size_t i = 0; i < pids.size(); ++i) { |
867 if (HANDLE_EINTR(waitpid(pids[i], &status, 0)) != -1) | 866 if (HANDLE_EINTR(waitpid(pids[i], &status, 0)) != -1) |
868 EXPECT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) == 0); | 867 EXPECT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) == 0); |
869 } | 868 } |
870 | 869 |
871 // No child should have the lock at this point, not even the crashed ones. | 870 // No child should have the lock at this point, not even the crashed ones. |
872 EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, | 871 EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, |
873 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); | 872 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); |
874 } | 873 } |
875 | 874 |
876 TEST_F(RlzLibTest, LockAcquistionSucceedsButPlistCannotBeCreated) { | 875 TEST_F(RlzLibTest, LockAcquistionSucceedsButStoreFileCannotBeCreated) { |
877 // See the comment at the top of WriteFails. | 876 // See the comment at the top of WriteFails. |
878 if (!rlz_lib::SupplementaryBranding::GetBrand().empty()) | 877 if (!rlz_lib::SupplementaryBranding::GetBrand().empty()) |
879 return; | 878 return; |
880 | 879 |
881 // Create a directory where the rlz file is supposed to appear. This way, | 880 // Create a directory where the rlz file is supposed to appear. This way, |
882 // the lock file can be created successfully, but creation of the rlz file | 881 // the lock file can be created successfully, but creation of the rlz file |
883 // itself will fail. | 882 // itself will fail. |
884 int mkdir_result = mkdir(rlz_lib::testing::RlzPlistFilenameStr().c_str(), | 883 int mkdir_result = mkdir(rlz_lib::testing::RlzStoreFilenameStr().c_str(), |
885 0500); | 884 0500); |
886 ASSERT_EQ(0, mkdir_result); | 885 ASSERT_EQ(0, mkdir_result); |
887 | 886 |
888 rlz_lib::SupplementaryBranding branding("TEST"); | 887 rlz_lib::SupplementaryBranding branding("TEST"); |
889 EXPECT_FALSE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, | 888 EXPECT_FALSE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, |
890 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); | 889 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); |
891 } | 890 } |
892 | 891 |
893 #endif | 892 #endif |
OLD | NEW |