OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/internal_api/syncapi_server_connection_manager.h" | 5 #include "chrome/browser/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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 ServerConnectionManager::PostBufferParams params; | 104 ServerConnectionManager::PostBufferParams params; |
105 ScopedServerStatusWatcher watcher(&server, ¶ms.response); | 105 ScopedServerStatusWatcher watcher(&server, ¶ms.response); |
106 | 106 |
107 base::Thread abort_thread("Test_AbortThread"); | 107 base::Thread abort_thread("Test_AbortThread"); |
108 ASSERT_TRUE(abort_thread.Start()); | 108 ASSERT_TRUE(abort_thread.Start()); |
109 abort_thread.message_loop()->PostDelayedTask( | 109 abort_thread.message_loop()->PostDelayedTask( |
110 FROM_HERE, | 110 FROM_HERE, |
111 base::Bind(&ServerConnectionManager::TerminateAllIO, | 111 base::Bind(&ServerConnectionManager::TerminateAllIO, |
112 base::Unretained(&server)), | 112 base::Unretained(&server)), |
113 TestTimeouts::tiny_timeout_ms()); | 113 TestTimeouts::tiny_timeout()); |
114 | 114 |
115 bool result = server.PostBufferToPath( | 115 bool result = server.PostBufferToPath( |
116 ¶ms, "/testpath", "testauth", &watcher); | 116 ¶ms, "/testpath", "testauth", &watcher); |
117 | 117 |
118 EXPECT_FALSE(result); | 118 EXPECT_FALSE(result); |
119 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, | 119 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, |
120 params.response.server_status); | 120 params.response.server_status); |
121 abort_thread.Stop(); | 121 abort_thread.Stop(); |
122 } | 122 } |
123 | 123 |
124 TEST(SyncAPIServerConnectionManagerTest, AbortCheckTime) { | 124 TEST(SyncAPIServerConnectionManagerTest, AbortCheckTime) { |
125 SyncAPIServerConnectionManager server( | 125 SyncAPIServerConnectionManager server( |
126 "server", 0, true, "1", new BlockingHttpPostFactory()); | 126 "server", 0, true, "1", new BlockingHttpPostFactory()); |
127 | 127 |
128 base::Thread abort_thread("Test_AbortThread"); | 128 base::Thread abort_thread("Test_AbortThread"); |
129 ASSERT_TRUE(abort_thread.Start()); | 129 ASSERT_TRUE(abort_thread.Start()); |
130 abort_thread.message_loop()->PostDelayedTask( | 130 abort_thread.message_loop()->PostDelayedTask( |
131 FROM_HERE, | 131 FROM_HERE, |
132 base::Bind(&ServerConnectionManager::TerminateAllIO, | 132 base::Bind(&ServerConnectionManager::TerminateAllIO, |
133 base::Unretained(&server)), | 133 base::Unretained(&server)), |
134 TestTimeouts::tiny_timeout_ms()); | 134 TestTimeouts::tiny_timeout()); |
135 | 135 |
136 int32 time = 0; | 136 int32 time = 0; |
137 bool result = server.CheckTime(&time); | 137 bool result = server.CheckTime(&time); |
138 EXPECT_FALSE(result); | 138 EXPECT_FALSE(result); |
139 abort_thread.Stop(); | 139 abort_thread.Stop(); |
140 } | 140 } |
141 | 141 |
142 } // namespace sync_api | 142 } // namespace sync_api |
OLD | NEW |