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.
5 #include "jingle/notifier/listener/push_client.h"
7 #include "base/bind_helpers.h"
8 #include "base/compiler_specific.h"
9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/threading/thread.h"
13 #include "jingle/notifier/base/notifier_options.h"
14 #include "net/url_request/url_request_test_util.h"
15 #include "testing/gtest/include/gtest/gtest.h"
21 class PushClientTest : public testing::Test {
24 notifier_options_.request_context_getter =
25 new net::TestURLRequestContextGetter(
26 message_loop_.message_loop_proxy());
29 virtual ~PushClientTest() {}
31 // The sockets created by the XMPP code expect an IO loop.
32 base::MessageLoopForIO message_loop_;
33 NotifierOptions notifier_options_;
36 // Make sure calling CreateDefault on the IO thread doesn't blow up.
37 TEST_F(PushClientTest, CreateDefaultOnIOThread) {
38 const scoped_ptr<PushClient> push_client(
39 PushClient::CreateDefault(notifier_options_));
42 // Make sure calling CreateDefault on a non-IO thread doesn't blow up.
43 TEST_F(PushClientTest, CreateDefaultOffIOThread) {
44 base::Thread thread("Non-IO thread");
45 EXPECT_TRUE(thread.Start());
46 thread.message_loop()->PostTask(
48 base::Bind(base::IgnoreResult(&PushClient::CreateDefault),
53 // Make sure calling CreateDefaultOnIOThread on the IO thread doesn't
55 TEST_F(PushClientTest, CreateDefaultOnIOThreadOnIOThread) {
56 const scoped_ptr<PushClient> push_client(
57 PushClient::CreateDefaultOnIOThread(notifier_options_));
62 } // namespace notifier