OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/copresence/chrome_whispernet_client.h" | 5 #include "chrome/browser/copresence/chrome_whispernet_client.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "chrome/browser/extensions/api/copresence/copresence_api.h" | 15 #include "chrome/browser/extensions/api/copresence/copresence_api.h" |
16 #include "chrome/browser/extensions/extension_browsertest.h" | 16 #include "chrome/browser/extensions/extension_browsertest.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "components/copresence/public/copresence_constants.h" | 20 #include "components/copresence/public/copresence_constants.h" |
21 #include "media/base/audio_bus.h" | 21 #include "media/base/audio_bus.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // TODO(rkc): Add more varied test input. | 25 // TODO(rkc): Add more varied test input. |
26 const char kSixZeros[] = "MDAwMDAw"; | 26 const char kSixZeros[] = "MDAwMDAw"; |
27 const char kEightZeros[] = "MDAwMDAwMDA="; | 27 const char kEightZeros[] = "MDAwMDAwMDA"; |
28 const char kNineZeros[] = "MDAwMDAwMDAw"; | 28 const char kNineZeros[] = "MDAwMDAwMDAw"; |
29 | 29 |
30 const size_t kTokenLengths[] = {6, 6}; | 30 const size_t kTokenLengths[] = {6, 6}; |
31 | 31 |
32 copresence::WhispernetClient* GetWhispernetClient( | 32 copresence::WhispernetClient* GetWhispernetClient( |
33 content::BrowserContext* context) { | 33 content::BrowserContext* context) { |
34 extensions::CopresenceService* service = | 34 extensions::CopresenceService* service = |
35 extensions::CopresenceService::GetFactoryInstance()->Get(context); | 35 extensions::CopresenceService::GetFactoryInstance()->Get(context); |
36 return service ? service->whispernet_client() : NULL; | 36 return service ? service->whispernet_client() : NULL; |
37 } | 37 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, TokenLengths) { | 207 IN_PROC_BROWSER_TEST_F(ChromeWhispernetClientTest, TokenLengths) { |
208 InitializeWhispernet(); | 208 InitializeWhispernet(); |
209 size_t kLongTokenLengths[2] = {8, 9}; | 209 size_t kLongTokenLengths[2] = {8, 9}; |
210 | 210 |
211 EncodeTokenAndSaveSamples(true, kEightZeros); | 211 EncodeTokenAndSaveSamples(true, kEightZeros); |
212 DecodeSamplesAndVerifyToken(true, kEightZeros, kLongTokenLengths); | 212 DecodeSamplesAndVerifyToken(true, kEightZeros, kLongTokenLengths); |
213 | 213 |
214 EncodeTokenAndSaveSamples(false, kNineZeros); | 214 EncodeTokenAndSaveSamples(false, kNineZeros); |
215 DecodeSamplesAndVerifyToken(false, kNineZeros, kLongTokenLengths); | 215 DecodeSamplesAndVerifyToken(false, kNineZeros, kLongTokenLengths); |
216 } | 216 } |
OLD | NEW |