Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: sync/internal_api/syncapi_server_connection_manager_unittest.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE { 63 virtual void Destroy(HttpPostProviderInterface* http) OVERRIDE {
64 delete static_cast<BlockingHttpPost*>(http); 64 delete static_cast<BlockingHttpPost*>(http);
65 } 65 }
66 }; 66 };
67 67
68 } // namespace 68 } // namespace
69 69
70 TEST(SyncAPIServerConnectionManagerTest, EarlyAbortPost) { 70 TEST(SyncAPIServerConnectionManagerTest, EarlyAbortPost) {
71 SyncAPIServerConnectionManager server( 71 SyncAPIServerConnectionManager server(
72 "server", 0, true, new BlockingHttpPostFactory()); 72 "server", 0, true, false, new BlockingHttpPostFactory());
73 73
74 ServerConnectionManager::PostBufferParams params; 74 ServerConnectionManager::PostBufferParams params;
75 ScopedServerStatusWatcher watcher(&server, &params.response); 75 ScopedServerStatusWatcher watcher(&server, &params.response);
76 76
77 server.TerminateAllIO(); 77 server.TerminateAllIO();
78 bool result = server.PostBufferToPath( 78 bool result = server.PostBufferToPath(
79 &params, "/testpath", "testauth", &watcher); 79 &params, "/testpath", "testauth", &watcher);
80 80
81 EXPECT_FALSE(result); 81 EXPECT_FALSE(result);
82 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, 82 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE,
83 params.response.server_status); 83 params.response.server_status);
84 } 84 }
85 85
86 TEST(SyncAPIServerConnectionManagerTest, AbortPost) { 86 TEST(SyncAPIServerConnectionManagerTest, AbortPost) {
87 SyncAPIServerConnectionManager server( 87 SyncAPIServerConnectionManager server(
88 "server", 0, true, new BlockingHttpPostFactory()); 88 "server", 0, true, false, new BlockingHttpPostFactory());
89 89
90 ServerConnectionManager::PostBufferParams params; 90 ServerConnectionManager::PostBufferParams params;
91 ScopedServerStatusWatcher watcher(&server, &params.response); 91 ScopedServerStatusWatcher watcher(&server, &params.response);
92 92
93 base::Thread abort_thread("Test_AbortThread"); 93 base::Thread abort_thread("Test_AbortThread");
94 ASSERT_TRUE(abort_thread.Start()); 94 ASSERT_TRUE(abort_thread.Start());
95 abort_thread.message_loop()->PostDelayedTask( 95 abort_thread.message_loop()->PostDelayedTask(
96 FROM_HERE, 96 FROM_HERE,
97 base::Bind(&ServerConnectionManager::TerminateAllIO, 97 base::Bind(&ServerConnectionManager::TerminateAllIO,
98 base::Unretained(&server)), 98 base::Unretained(&server)),
99 TestTimeouts::tiny_timeout()); 99 TestTimeouts::tiny_timeout());
100 100
101 bool result = server.PostBufferToPath( 101 bool result = server.PostBufferToPath(
102 &params, "/testpath", "testauth", &watcher); 102 &params, "/testpath", "testauth", &watcher);
103 103
104 EXPECT_FALSE(result); 104 EXPECT_FALSE(result);
105 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE, 105 EXPECT_EQ(HttpResponse::CONNECTION_UNAVAILABLE,
106 params.response.server_status); 106 params.response.server_status);
107 abort_thread.Stop(); 107 abort_thread.Stop();
108 } 108 }
109 109
110 } // namespace syncer 110 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/syncapi_server_connection_manager.cc ('k') | sync/internal_api/test/fake_sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698