| 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 "sync/internal_api/syncapi_server_connection_manager.h" | 5 #include "sync/internal_api/syncapi_server_connection_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 10 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "sync/internal_api/public/base/cancelation_signal.h" | 16 #include "sync/internal_api/public/base/cancelation_signal.h" |
| 16 #include "sync/internal_api/public/http_post_provider_factory.h" | 17 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 17 #include "sync/internal_api/public/http_post_provider_interface.h" | 18 #include "sync/internal_api/public/http_post_provider_interface.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Ask the ServerConnectionManager to stop during a request. | 102 // Ask the ServerConnectionManager to stop during a request. |
| 102 TEST(SyncAPIServerConnectionManagerTest, AbortPost) { | 103 TEST(SyncAPIServerConnectionManagerTest, AbortPost) { |
| 103 CancelationSignal signal; | 104 CancelationSignal signal; |
| 104 SyncAPIServerConnectionManager server( | 105 SyncAPIServerConnectionManager server( |
| 105 "server", 0, true, new BlockingHttpPostFactory(), &signal); | 106 "server", 0, true, new BlockingHttpPostFactory(), &signal); |
| 106 | 107 |
| 107 ServerConnectionManager::PostBufferParams params; | 108 ServerConnectionManager::PostBufferParams params; |
| 108 | 109 |
| 109 base::Thread abort_thread("Test_AbortThread"); | 110 base::Thread abort_thread("Test_AbortThread"); |
| 110 ASSERT_TRUE(abort_thread.Start()); | 111 ASSERT_TRUE(abort_thread.Start()); |
| 111 abort_thread.message_loop()->PostDelayedTask( | 112 abort_thread.task_runner()->PostDelayedTask( |
| 112 FROM_HERE, | 113 FROM_HERE, |
| 113 base::Bind(&CancelationSignal::Signal, | 114 base::Bind(&CancelationSignal::Signal, base::Unretained(&signal)), |
| 114 base::Unretained(&signal)), | |
| 115 TestTimeouts::tiny_timeout()); | 115 TestTimeouts::tiny_timeout()); |
| 116 | 116 |
| 117 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); | 117 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); |
| 118 | 118 |
| 119 EXPECT_FALSE(result); | 119 EXPECT_FALSE(result); |
| 120 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, | 120 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, |
| 121 params.response.server_status); | 121 params.response.server_status); |
| 122 abort_thread.Stop(); | 122 abort_thread.Stop(); |
| 123 } | 123 } |
| 124 | 124 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 ServerConnectionManager::PostBufferParams params; | 182 ServerConnectionManager::PostBufferParams params; |
| 183 | 183 |
| 184 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); | 184 bool result = server.PostBufferToPath(¶ms, "/testpath", "testauth"); |
| 185 | 185 |
| 186 EXPECT_FALSE(result); | 186 EXPECT_FALSE(result); |
| 187 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, | 187 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, |
| 188 params.response.server_status); | 188 params.response.server_status); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace syncer | 191 } // namespace syncer |
| OLD | NEW |