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.
8 #include "base/message_loop.h"
9 #include "sync/util/get_session_name.h"
10 #include "testing/gtest/include/gtest/gtest.h"
16 class GetSessionNameTest
: public ::testing::Test
{
18 void SetSessionNameAndQuit(const std::string
& session_name
) {
19 session_name_
= session_name
;
24 MessageLoop message_loop_
;
25 std::string session_name_
;
28 // Call GetSessionNameSynchronouslyForTesting and make sure its return
30 TEST_F(GetSessionNameTest
, GetSessionNameSynchronously
) {
31 const std::string
& session_name
= GetSessionNameSynchronouslyForTesting();
32 EXPECT_FALSE(session_name
.empty());
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)));
43 EXPECT_EQ(session_name_
, GetSessionNameSynchronouslyForTesting());