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

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

Issue 2058513006: Send API error response when chrome.socket.* API receives an invalid port number. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | extensions/browser/api/socket/socket_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 5 #include <memory>
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/browser_process_impl.h" 9 #include "chrome/browser/browser_process_impl.h"
10 #include "chrome/browser/extensions/extension_api_unittest.h" 10 #include "chrome/browser/extensions/extension_api_unittest.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Create SocketCreateFunction and put it on BrowserThread 42 // Create SocketCreateFunction and put it on BrowserThread
43 SocketCreateFunction* function = new SocketCreateFunction(); 43 SocketCreateFunction* function = new SocketCreateFunction();
44 function->set_work_thread_id(id); 44 function->set_work_thread_id(id);
45 45
46 // Run tests 46 // Run tests
47 std::unique_ptr<base::DictionaryValue> result( 47 std::unique_ptr<base::DictionaryValue> result(
48 RunFunctionAndReturnDictionary(function, "[\"tcp\"]")); 48 RunFunctionAndReturnDictionary(function, "[\"tcp\"]"));
49 ASSERT_TRUE(result.get()); 49 ASSERT_TRUE(result.get());
50 } 50 }
51 51
52 TEST_F(SocketUnitTest, InvalidPort) {
53 const std::string kError = "Port must be a value between 0 and 65535.";
54
55 SocketConnectFunction* connect_function = new SocketConnectFunction();
56 EXPECT_EQ(kError,
57 RunFunctionAndReturnError(connect_function, "[1, \"foo\", -1]"));
58 SocketBindFunction* bind_function = new SocketBindFunction();
59 EXPECT_EQ(kError,
60 RunFunctionAndReturnError(bind_function, "[1, \"foo\", -1]"));
61 }
62
52 } // namespace extensions 63 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698