| 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/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "sync/util/get_session_name.h" | 10 #include "sync/util/get_session_name.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 #if defined(OS_CHROMEOS) | 13 #if defined(OS_CHROMEOS) |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 16 #endif // OS_CHROMEOS | 16 #endif // OS_CHROMEOS |
| 17 | 17 |
| 18 namespace syncer { | 18 namespace syncer { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class GetSessionNameTest : public ::testing::Test { | 22 class GetSessionNameTest : public ::testing::Test { |
| 23 public: | 23 public: |
| 24 void SetSessionNameAndQuit(const std::string& session_name) { | 24 void SetSessionNameAndQuit(const std::string& session_name) { |
| 25 session_name_ = session_name; | 25 session_name_ = session_name; |
| 26 message_loop_.Quit(); | 26 message_loop_.QuitWhenIdle(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 protected: | 29 protected: |
| 30 base::MessageLoop message_loop_; | 30 base::MessageLoop message_loop_; |
| 31 std::string session_name_; | 31 std::string session_name_; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // Call GetSessionNameSynchronouslyForTesting and make sure its return | 34 // Call GetSessionNameSynchronouslyForTesting and make sure its return |
| 35 // value looks sane. | 35 // value looks sane. |
| 36 TEST_F(GetSessionNameTest, GetSessionNameSynchronously) { | 36 TEST_F(GetSessionNameTest, GetSessionNameSynchronously) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 GetSessionName(message_loop_.task_runner(), | 67 GetSessionName(message_loop_.task_runner(), |
| 68 base::Bind(&GetSessionNameTest::SetSessionNameAndQuit, | 68 base::Bind(&GetSessionNameTest::SetSessionNameAndQuit, |
| 69 base::Unretained(this))); | 69 base::Unretained(this))); |
| 70 message_loop_.Run(); | 70 message_loop_.Run(); |
| 71 EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting()); | 71 EXPECT_EQ(session_name_, GetSessionNameSynchronouslyForTesting()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 } // namespace syncer | 76 } // namespace syncer |
| OLD | NEW |