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 // Main entry point for all unit tests. | 5 // Main entry point for all unit tests. |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "rlz/lib/rlz_lib.h" | 9 #include "rlz/lib/rlz_lib.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 #if defined(OS_POSIX) | 13 #if defined(OS_POSIX) |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
16 #include "rlz/lib/rlz_value_store.h" | 16 #include "rlz/lib/rlz_value_store.h" |
17 #endif | 17 #endif |
18 | 18 |
19 int main(int argc, char **argv) { | 19 int main(int argc, char **argv) { |
20 base::AtExitManager at_exit; | 20 base::AtExitManager at_exit; |
21 CommandLine::Init(argc, argv); | 21 base::CommandLine::Init(argc, argv); |
22 | 22 |
23 testing::InitGoogleMock(&argc, argv); | 23 testing::InitGoogleMock(&argc, argv); |
24 testing::InitGoogleTest(&argc, argv); | 24 testing::InitGoogleTest(&argc, argv); |
25 | 25 |
26 int ret = RUN_ALL_TESTS(); | 26 int ret = RUN_ALL_TESTS(); |
27 if (ret == 0) { | 27 if (ret == 0) { |
28 // Now re-run all the tests using a supplementary brand code. This brand | 28 // Now re-run all the tests using a supplementary brand code. This brand |
29 // code will remain in effect for the lifetime of the branding object. | 29 // code will remain in effect for the lifetime of the branding object. |
30 #if defined(OS_POSIX) | 30 #if defined(OS_POSIX) |
31 // Set a temporary directory for RLZ here, because SupplementaryBranding | 31 // Set a temporary directory for RLZ here, because SupplementaryBranding |
32 // creates and owns RlzValueStore object for its lifetime. | 32 // creates and owns RlzValueStore object for its lifetime. |
33 base::ScopedTempDir temp_dir; | 33 base::ScopedTempDir temp_dir; |
34 if (temp_dir.CreateUniqueTempDir()) | 34 if (temp_dir.CreateUniqueTempDir()) |
35 rlz_lib::testing::SetRlzStoreDirectory(temp_dir.path()); | 35 rlz_lib::testing::SetRlzStoreDirectory(temp_dir.path()); |
36 #endif | 36 #endif |
37 rlz_lib::SupplementaryBranding branding("TEST"); | 37 rlz_lib::SupplementaryBranding branding("TEST"); |
38 ret = RUN_ALL_TESTS(); | 38 ret = RUN_ALL_TESTS(); |
39 } | 39 } |
40 | 40 |
41 return ret; | 41 return ret; |
42 } | 42 } |
OLD | NEW |