OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include <string> | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/message_loop.h" | |
9 #include "chrome/browser/sync/util/get_session_name.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace browser_sync { | |
13 | |
14 namespace { | |
15 | |
16 class GetSessionNameTest : public ::testing::Test { | |
17 public: | |
18 void SetSessionNameAndQuit(const std::string& session_name) { | |
19 session_name_ = session_name; | |
20 message_loop_.Quit(); | |
21 } | |
22 | |
23 protected: | |
24 MessageLoop message_loop_; | |
25 std::string session_name_; | |
26 }; | |
27 | |
28 // Call GetSessionNameSynchronouslyForTesting and make sure its return | |
29 // value looks sane. | |
30 TEST_F(GetSessionNameTest, GetSessionNameSynchronously) { | |
31 const std::string& session_name = GetSessionNameSynchronouslyForTesting(); | |
32 EXPECT_FALSE(session_name.empty()); | |
33 } | |
34 | |
35 // Calls GetSessionName and runs the message loop until it comes back | |
36 // with a session name. Makes sure the returned session name is equal | |
37 // to the return value of GetSessionNameSynchronouslyForTesting(). | |
38 TEST_F(GetSessionNameTest, GetSessionName) { | |
39 GetSessionName(message_loop_.message_loop_proxy(), | |
40 base::Bind(&GetSessionNameTest::SetSessionNameAndQuit, | |
41 base::Unretained(this))); | |
42 message_loop_.Run(); | |
43 EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting()); | |
44 } | |
45 | |
46 } // namespace | |
47 | |
48 } // namespace browser_sync | |
OLD | NEW |