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

Side by Side Diff: chrome/browser/extensions/api/socket/socket_api_controller_unittest.cc

Issue 8743017: Real (but naive) UDP socket sending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Post-try-server fixes. Created 9 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/extensions/api/socket/socket_api.h"
9 #include "chrome/browser/extensions/api/socket/socket_api_controller.h"
10
11 namespace extensions {
12
13 class SocketApiControllerTest : public testing::Test {
14 };
15
16 TEST_F(SocketApiControllerTest, TestSocketControllerLifetime) {
17 // We want to make sure that killing the controller while a bunch of
18 // sockets are alive doesn't crash.
19 SocketController* controller = SocketController::GetInstance();
20
21 // Create some sockets but don't do anything with them.
22 Profile* profile = NULL;
23 const std::string extension_id("xxxxxxxxx");
24 const GURL url;
25 for (int i = 0; i < 10; ++i) {
26 int socket_id = controller->CreateUdp(profile, extension_id, url);
27 ASSERT_TRUE(socket_id != 0);
28 }
29
30 // Create some more sockets and connect them. Note that because this is
31 // UDP, we can happily "connect" a UDP socket without anyone listening.
32 const int kPort = 38888;
33 const std::string address("127.0.0.1");
34 for (int i = 0; i < 10; ++i) {
35 int socket_id = controller->CreateUdp(profile, extension_id, url);
36 ASSERT_TRUE(socket_id != 0);
37 ASSERT_TRUE(controller->ConnectUdp(socket_id, address, kPort));
38 }
39
40 // At this point, we're done, and we're relying on the RAE mechanism
41 // of the Singleton class to delete the controller at process exit.
42 // We'd have to jump through some icky hoops to turn off RAE and
43 // manually delete in this test method, so we'll instead take it on
44 // faith that the singleton will indeed delete itself, and that if
45 // we had any heap management problems in the controller, they'd
46 // show up later in this test process. I (miket) hereby confirm that
47 // I manually added a temporary double-free in the controller
48 // destructor and verified that the unit_tests process segfaulted.
49 }
50
51 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698