OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 "chrome/browser/net/keygen_handler.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/base64.h" |
| 10 #include "base/bind.h" |
| 11 #include "base/run_loop.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_io_data.h" |
| 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/test/base/in_process_browser_test.h" |
| 16 #include "net/base/keygen_handler_test_util.h" |
| 17 |
| 18 namespace { |
| 19 |
| 20 void KeygenComplete(std::string* output_result, |
| 21 base::RunLoop* run_loop, |
| 22 const std::string* input_result) { |
| 23 if (input_result) |
| 24 *output_result = *input_result; |
| 25 run_loop->Quit(); |
| 26 } |
| 27 |
| 28 class ChromeKeygenHandlerTest : public InProcessBrowserTest { |
| 29 public: |
| 30 ChromeKeygenHandlerTest() {} |
| 31 |
| 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(ChromeKeygenHandlerTest); |
| 34 }; |
| 35 |
| 36 } // namespace |
| 37 |
| 38 IN_PROC_BROWSER_TEST_F(ChromeKeygenHandlerTest, ConcurrencyTest) { |
| 39 const int NUM_HANDLERS = 5; |
| 40 std::string results[NUM_HANDLERS]; |
| 41 base::RunLoop run_loop[NUM_HANDLERS]; |
| 42 for (int i = 0; i < NUM_HANDLERS; i++) { |
| 43 chrome_browser_net::Keygen( |
| 44 browser()->profile()->GetResourceContext(), |
| 45 768, |
| 46 "some challenge", |
| 47 GURL("http://www.example.com"), |
| 48 false, |
| 49 base::Bind(&KeygenComplete, &results[i], &run_loop[i])); |
| 50 } |
| 51 |
| 52 for (int i = 0; i < NUM_HANDLERS; i++) { |
| 53 run_loop[i].Run(); |
| 54 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; |
| 55 net::AssertValidSignedPublicKeyAndChallenge( |
| 56 results[i], 768, "some challenge"); |
| 57 } |
| 58 } |
OLD | NEW |