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 // |
11 // These tests require write access to HKLM and HKCU. | 11 // These tests require write access to HKLM and HKCU. |
12 // | 12 // |
13 // The "GGLA" brand is used to test the normal code flow of the code, and the | 13 // The "GGLA" brand is used to test the normal code flow of the code, and the |
14 // "TEST" brand is used to test the supplementary brand code code flow. | 14 // "TEST" brand is used to test the supplementary brand code code flow. |
15 | 15 |
16 #include "base/eintr_wrapper.h" | 16 #include "base/eintr_wrapper.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 #include "rlz/lib/rlz_lib.h" | 22 #include "rlz/lib/rlz_lib.h" |
23 #include "rlz/test/rlz_test_helpers.h" | 23 #include "rlz/test/rlz_test_helpers.h" |
24 | 24 |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 #include <Windows.h> | 26 #include <Windows.h> |
27 #include "rlz/win/lib/machine_deal.h" | 27 #include "rlz/win/lib/machine_deal.h" |
28 #elif defined(OS_MACOSX) | |
29 namespace rlz_lib { | |
30 namespace testing { | |
31 std::string RlzPlistFilenameStr(); | |
32 } | |
33 } | |
Nico
2012/08/21 20:43:44
This is a bit gross, but rlz_value_store_mac.h can
Mark Mentovai
2012/08/21 20:59:29
Nico wrote:
Nico
2012/08/21 21:05:03
The included of scoped_nsobject.h needs to be cond
| |
28 #endif | 34 #endif |
29 | 35 |
30 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) | 36 #if defined(RLZ_NETWORK_IMPLEMENTATION_CHROME_NET) |
31 #include "base/mac/scoped_nsautorelease_pool.h" | 37 #include "base/mac/scoped_nsautorelease_pool.h" |
32 #include "base/threading/thread.h" | 38 #include "base/threading/thread.h" |
33 #include "net/url_request/url_request_test_util.h" | 39 #include "net/url_request/url_request_test_util.h" |
34 #endif | 40 #endif |
35 | 41 |
36 | 42 |
37 class MachineDealCodeHelper | 43 class MachineDealCodeHelper |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 int status; | 870 int status; |
865 for (size_t i = 0; i < pids.size(); ++i) { | 871 for (size_t i = 0; i < pids.size(); ++i) { |
866 if (HANDLE_EINTR(waitpid(pids[i], &status, 0)) != -1) | 872 if (HANDLE_EINTR(waitpid(pids[i], &status, 0)) != -1) |
867 EXPECT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) == 0); | 873 EXPECT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) == 0); |
868 } | 874 } |
869 | 875 |
870 // No child should have the lock at this point, not even the crashed ones. | 876 // No child should have the lock at this point, not even the crashed ones. |
871 EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, | 877 EXPECT_TRUE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, |
872 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); | 878 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); |
873 } | 879 } |
880 | |
881 TEST_F(RlzLibTest, LockAcquistionSucceedsButPlistCannotBeCreated) { | |
882 // See the comment at the top of WriteFails. | |
883 if (!rlz_lib::SupplementaryBranding::GetBrand().empty()) | |
884 return; | |
885 | |
886 // Create a directory where the rlz file is supposed to appear. This way, | |
887 // the lock file can be created successfully, but creation of the rlz file | |
888 // itself will fail. | |
889 int mkdir_result = mkdir(rlz_lib::testing::RlzPlistFilenameStr().c_str(), | |
890 0500); | |
Mark Mentovai
2012/08/21 20:59:29
Bump this over to line up with the other argument.
| |
891 ASSERT_EQ(0, mkdir_result); | |
892 | |
893 rlz_lib::SupplementaryBranding branding("TEST"); | |
894 EXPECT_FALSE(rlz_lib::RecordProductEvent(rlz_lib::TOOLBAR_NOTIFIER, | |
895 rlz_lib::IE_DEFAULT_SEARCH, rlz_lib::INSTALL)); | |
896 } | |
897 | |
874 #endif | 898 #endif |
OLD | NEW |