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

Side by Side Diff: chrome/browser/copresence/chrome_whispernet_client_browsertest.cc

Issue 1892433002: Moving device description utils from AudioManager[Base] into AudioDeviceDescription; to be shared b… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 4 years, 7 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 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <cstdlib> 10 #include <cstdlib>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/extensions/api/copresence/copresence_api.h" 19 #include "chrome/browser/extensions/api/copresence/copresence_api.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 20 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "components/audio_modem/public/audio_modem_types.h" 24 #include "components/audio_modem/public/audio_modem_types.h"
25 #include "components/audio_modem/public/whispernet_client.h" 25 #include "components/audio_modem/public/whispernet_client.h"
26 #include "media/audio/audio_device_description.h"
26 #include "media/audio/audio_manager.h" 27 #include "media/audio/audio_manager.h"
27 #include "media/audio/audio_manager_base.h" 28 #include "media/audio/audio_manager_base.h"
28 #include "media/base/audio_bus.h" 29 #include "media/base/audio_bus.h"
29 #include "media/base/audio_converter.h" 30 #include "media/base/audio_converter.h"
30 #include "media/base/audio_parameters.h" 31 #include "media/base/audio_parameters.h"
31 32
32 using audio_modem::WhispernetClient; 33 using audio_modem::WhispernetClient;
33 using audio_modem::AUDIBLE; 34 using audio_modem::AUDIBLE;
34 using audio_modem::INAUDIBLE; 35 using audio_modem::INAUDIBLE;
35 using audio_modem::TokenParameters; 36 using audio_modem::TokenParameters;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // manager seems to get initialized only *after* ExtensionBrowserTest::SetUp 95 // manager seems to get initialized only *after* ExtensionBrowserTest::SetUp
95 // has finished executing. Setting up a testing AudioMager causes the actual 96 // has finished executing. Setting up a testing AudioMager causes the actual
96 // create happening later in the browser initialization to fail. The only way 97 // create happening later in the browser initialization to fail. The only way
97 // around this at the moment seems to be to have this method called from 98 // around this at the moment seems to be to have this method called from
98 // every test before they try to decode. 99 // every test before they try to decode.
99 void SetupDecode() { 100 void SetupDecode() {
100 // We get default parameters here instead of the constructor since 101 // We get default parameters here instead of the constructor since
101 // initializing Whispernet also creates our AudioManager. Initializing from 102 // initializing Whispernet also creates our AudioManager. Initializing from
102 // the test instead causes issues. 103 // the test instead causes issues.
103 default_params_ = media::AudioManager::Get()->GetInputStreamParameters( 104 default_params_ = media::AudioManager::Get()->GetInputStreamParameters(
104 media::AudioManagerBase::kDefaultDeviceId); 105 media::AudioDeviceDescription::kDefaultDeviceId);
105 106
106 coder_params_ = media::AudioParameters( 107 coder_params_ = media::AudioParameters(
107 default_params_.format(), audio_modem::kDefaultChannelLayout, 108 default_params_.format(), audio_modem::kDefaultChannelLayout,
108 audio_modem::kDefaultSampleRate, audio_modem::kDefaultBitsPerSample, 109 audio_modem::kDefaultSampleRate, audio_modem::kDefaultBitsPerSample,
109 default_params_.frames_per_buffer()); 110 default_params_.frames_per_buffer());
110 111
111 converter_.reset(new media::AudioConverter( 112 converter_.reset(new media::AudioConverter(
112 coder_params_, default_params_, 113 coder_params_, default_params_,
113 default_params_.sample_rate() == coder_params_.sample_rate())); 114 default_params_.sample_rate() == coder_params_.sample_rate()));
114 converter_->AddInput(this); 115 converter_->AddInput(this);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 367
367 EncodeTokenAndSaveSamples(client_3.get(), true, kSixZeros, token_params); 368 EncodeTokenAndSaveSamples(client_3.get(), true, kSixZeros, token_params);
368 DecodeSamplesAndVerifyToken(client_3.get(), true, kSixZeros, token_params); 369 DecodeSamplesAndVerifyToken(client_3.get(), true, kSixZeros, token_params);
369 370
370 const size_t kLongTokenLengths[2] = {8, 9}; 371 const size_t kLongTokenLengths[2] = {8, 9};
371 GetTokenParamsForLengths(kLongTokenLengths, token_params); 372 GetTokenParamsForLengths(kLongTokenLengths, token_params);
372 373
373 EncodeTokenAndSaveSamples(client_2.get(), true, kEightZeros, token_params); 374 EncodeTokenAndSaveSamples(client_2.get(), true, kEightZeros, token_params);
374 DecodeSamplesAndVerifyToken(client_2.get(), true, kEightZeros, token_params); 375 DecodeSamplesAndVerifyToken(client_2.get(), true, kEightZeros, token_params);
375 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698