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 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "sync/util/get_session_name.h" | 9 #include "sync/util/get_session_name.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if defined(OS_CHROMEOS) | 12 #if defined(OS_CHROMEOS) |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "chromeos/chromeos_switches.h" | 14 #include "chromeos/chromeos_switches.h" |
15 #endif // OS_CHROMEOS | 15 #endif // OS_CHROMEOS |
16 | 16 |
17 namespace syncer { | 17 namespace syncer { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 class GetSessionNameTest : public ::testing::Test { | 21 class GetSessionNameTest : public ::testing::Test { |
22 public: | 22 public: |
23 void SetSessionNameAndQuit(const std::string& session_name) { | 23 void SetSessionNameAndQuit(const std::string& session_name) { |
24 session_name_ = session_name; | 24 session_name_ = session_name; |
25 message_loop_.Quit(); | 25 message_loop_.Quit(); |
26 } | 26 } |
27 | 27 |
28 protected: | 28 protected: |
29 MessageLoop message_loop_; | 29 base::MessageLoop message_loop_; |
30 std::string session_name_; | 30 std::string session_name_; |
31 }; | 31 }; |
32 | 32 |
33 // Call GetSessionNameSynchronouslyForTesting and make sure its return | 33 // Call GetSessionNameSynchronouslyForTesting and make sure its return |
34 // value looks sane. | 34 // value looks sane. |
35 TEST_F(GetSessionNameTest, GetSessionNameSynchronously) { | 35 TEST_F(GetSessionNameTest, GetSessionNameSynchronously) { |
36 const std::string& session_name = GetSessionNameSynchronouslyForTesting(); | 36 const std::string& session_name = GetSessionNameSynchronouslyForTesting(); |
37 EXPECT_FALSE(session_name.empty()); | 37 EXPECT_FALSE(session_name.empty()); |
38 } | 38 } |
39 | 39 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 GetSessionName(message_loop_.message_loop_proxy(), | 80 GetSessionName(message_loop_.message_loop_proxy(), |
81 base::Bind(&GetSessionNameTest::SetSessionNameAndQuit, | 81 base::Bind(&GetSessionNameTest::SetSessionNameAndQuit, |
82 base::Unretained(this))); | 82 base::Unretained(this))); |
83 message_loop_.Run(); | 83 message_loop_.Run(); |
84 EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting()); | 84 EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting()); |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 } // namespace syncer | 89 } // namespace syncer |
OLD | NEW |