OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/process_util.h" | 6 #include "base/process_util.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/common/chrome_version_info.h" | 8 #include "chrome/common/chrome_version_info.h" |
9 #include "chrome/common/service_process_util.h" | 9 #include "chrome/common/service_process_util.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 | 12 |
13 TEST(ServiceProcessUtilTest, ScopedVersionedName) { | 13 TEST(ServiceProcessUtilTest, ScopedVersionedName) { |
14 std::string test_str = "test"; | 14 std::string test_str = "test"; |
15 std::string scoped_name = GetServiceProcessScopedVersionedName(test_str); | 15 std::string scoped_name = GetServiceProcessScopedVersionedName(test_str); |
16 chrome::VersionInfo version_info; | 16 chrome::VersionInfo version_info; |
17 DCHECK(version_info.is_valid()); | |
18 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); | 17 EXPECT_TRUE(EndsWith(scoped_name, test_str, true)); |
19 EXPECT_NE(std::string::npos, scoped_name.find(version_info.Version())); | 18 EXPECT_NE(std::string::npos, scoped_name.find(version_info.Version())); |
20 } | 19 } |
21 | 20 |
22 class ServiceProcessStateTest : public testing::Test { | 21 class ServiceProcessStateTest : public testing::Test { |
23 private: | 22 private: |
24 // This is used to release the ServiceProcessState singleton after each test. | 23 // This is used to release the ServiceProcessState singleton after each test. |
25 base::ShadowingAtExitManager at_exit_manager_; | 24 base::ShadowingAtExitManager at_exit_manager_; |
26 }; | 25 }; |
27 | 26 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // GetServiceProcessPid to lie. On Windows, we use a named event so we | 63 // GetServiceProcessPid to lie. On Windows, we use a named event so we |
65 // don't have this issue. Until we have a more stable shared memory | 64 // don't have this issue. Until we have a more stable shared memory |
66 // implementation on Posix, this check will only execute on Windows. | 65 // implementation on Posix, this check will only execute on Windows. |
67 EXPECT_EQ(0, GetServiceProcessPid()); | 66 EXPECT_EQ(0, GetServiceProcessPid()); |
68 #endif // defined(OS_WIN) | 67 #endif // defined(OS_WIN) |
69 ServiceProcessState* state = ServiceProcessState::GetInstance(); | 68 ServiceProcessState* state = ServiceProcessState::GetInstance(); |
70 EXPECT_TRUE(state->Initialize()); | 69 EXPECT_TRUE(state->Initialize()); |
71 EXPECT_EQ(base::GetCurrentProcId(), GetServiceProcessPid()); | 70 EXPECT_EQ(base::GetCurrentProcId(), GetServiceProcessPid()); |
72 } | 71 } |
73 | 72 |
OLD | NEW |