#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "content/browser/speech/network_speech_recognition_engine_impl.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/containers/queue.h"
#include "base/containers/span.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "components/speech/audio_buffer.h"
#include "content/browser/speech/speech_recognition_engine.h"
#include "content/public/browser/google_streaming_api.pb.h"
#include "media/mojo/mojom/speech_recognition_error.mojom.h"
#include "media/mojo/mojom/speech_recognition_result.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
static const uint32_t kFrameTypePreamble = …;
static const uint32_t kFrameTypeRecognitionAudio = …;
class NetworkSpeechRecognitionEngineImplTest
: public SpeechRecognitionEngine::Delegate,
public testing::Test { … };
TEST_F(NetworkSpeechRecognitionEngineImplTest, SingleDefinitiveResult) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, SeveralStreamingResults) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest,
NoFinalResultAfterAudioChunksEnded) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, ReRequestData) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, NoMatchError) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, HTTPError) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, NetworkError) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, Stability) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, EndOfUtterance) { … }
TEST_F(NetworkSpeechRecognitionEngineImplTest, SendPreamble) { … }
void NetworkSpeechRecognitionEngineImplTest::SetUp() { … }
void NetworkSpeechRecognitionEngineImplTest::TearDown() { … }
const network::TestURLLoaderFactory::PendingRequest*
NetworkSpeechRecognitionEngineImplTest::GetUpstreamRequest() { … }
const network::TestURLLoaderFactory::PendingRequest*
NetworkSpeechRecognitionEngineImplTest::GetDownstreamRequest() { … }
void NetworkSpeechRecognitionEngineImplTest::StartMockRecognition() { … }
void NetworkSpeechRecognitionEngineImplTest::EndMockRecognition() { … }
void NetworkSpeechRecognitionEngineImplTest::InjectDummyAudioChunk() { … }
void NetworkSpeechRecognitionEngineImplTest::
ProvideMockResponseStartDownstreamIfNeeded() { … }
void NetworkSpeechRecognitionEngineImplTest::ProvideMockProtoResultDownstream(
const proto::SpeechRecognitionEvent& result) { … }
void NetworkSpeechRecognitionEngineImplTest::ProvideMockResultDownstream(
const media::mojom::WebSpeechRecognitionResultPtr& result) { … }
void NetworkSpeechRecognitionEngineImplTest::CloseMockDownstream(
DownstreamError error) { … }
void NetworkSpeechRecognitionEngineImplTest::ExpectResultsReceived(
const std::vector<media::mojom::WebSpeechRecognitionResultPtr>& results) { … }
bool NetworkSpeechRecognitionEngineImplTest::ResultsAreEqual(
const std::vector<media::mojom::WebSpeechRecognitionResultPtr>& a,
const std::vector<media::mojom::WebSpeechRecognitionResultPtr>& b) { … }
void NetworkSpeechRecognitionEngineImplTest::ExpectFramedChunk(
const std::string& chunk, uint32_t type) { … }
std::string NetworkSpeechRecognitionEngineImplTest::ConsumeChunkedUploadData() { … }
std::string NetworkSpeechRecognitionEngineImplTest::SerializeProtobufResponse(
const proto::SpeechRecognitionEvent& msg) { … }
}