avs-device-sdk/AVSCommon/Utils/test/LogEntryStreamTest.cpp

100 lines
3.5 KiB
C++
Raw Normal View History

/*
Version 1.5.0 alexa-client-sdk Changes in this update: **Enhancements** * Added the `ExternalMediaPlayer` Capability Agent. This allows playback from music providers that control their own playback queue. Example: Spotify. * Added support for AU and NZ to the `SampleApp`. * Firmware version can now be sent to Alexa via the `SoftwareInfo` event. The firmware version is specified in the config file under the `sampleApp` object as an integer value named [`firmwareVersion`](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L52). * The new `f` command was added to the `SampleApp` which allows the firmware version to be updated at run-time. * Optional configuration changes have been introduced. Now a [default log level](https://github.com/alexa/avs-device-sdk/blob/master/Integration/AlexaClientSDKConfig.json#L93) can be set for `ACSDK_LOG_MODULE` components, globally or individually. This value is specified under a new root level configuration object called `logger`, and the value itself is named `logLevel`. This allows you to limit the degree of logging to that default value, such as `ERROR`or `INFO`. **Bug Fixes** * Fixed bug where `AudioPlayer` progress reports were not being sent, or were being sent incorrectly. * [Issue 408](https://github.com/alexa/avs-device-sdk/issues/408) - Irrelevant code related to `UrlSource` was removed from the `GStreamer-based MediaPlayer` implementation. * The `TZ` variable no longer needs to be set to `UTC` when building the `SampleApp`. * Fixed a bug where `CurlEasyHandleWrapper` logged unwanted data on failure conditions. * Fixed a bug to improve `SIGPIPE` handling. * Fixed a bug where the filename and classname were mismatched. Changed `UrlToAttachmentConverter.h` to `UrlContentToAttachmentConverter.h`,and `UrlToAttachmentConverter.cpp` to `UrlContentToAttachmentConverter.cpp` **Known Issues** * The `ACL` may encounter issues if audio attachments are received but not consumed. * Display Cards for Kindle don't render. * If using the GStreamer-based `MediaPlayer` implementation, after muting and un-muting an audio item, the next item in the queue will begin playing rather than continuing playback of the originally muted audio item. * `SpeechSynthesizerState` currently uses `GAINING_FOCUS` and `LOSING_FOCUS` as a workaround for handling intermediate state. These states may be removed in a future release. * Music playback doesn't immediately stop when a user barges-in on iHeartRadio.
2018-02-12 23:31:53 +00:00
* Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "AVSCommon/Utils/Logger/LogEntryStream.h"
namespace alexaClientSDK {
namespace avsCommon {
namespace utils {
namespace logger {
namespace test {
using namespace ::testing;
/**
* Class for testing the LogEntryStream class
*/
class LogEntryStreamTest : public ::testing::Test {
protected:
/// The LogEntryStream to test.
LogEntryStream m_stream;
};
/// Test that a new LogEntryStream instance's c_str() returns an empty string.
TEST_F(LogEntryStreamTest, emptyStream) {
ASSERT_NE(m_stream.c_str(), nullptr);
ASSERT_EQ(strlen(m_stream.c_str()), 0u);
}
/// Send a character to an empty LogEntryStream. Expect that c_str() returns a string with just that character.
TEST_F(LogEntryStreamTest, shortString) {
const char SOME_CHAR = 'x';
m_stream << SOME_CHAR;
ASSERT_EQ(SOME_CHAR, m_stream.c_str()[0]);
ASSERT_EQ(strlen(m_stream.c_str()), 1u);
}
/// Send a medium sized string test to an empty LogEntryStream. Expect that c_str() returns a matching string.
TEST_F(LogEntryStreamTest, mediumString) {
const std::string MEDIUM_STRING = "Hello World!";
m_stream << MEDIUM_STRING;
ASSERT_EQ(MEDIUM_STRING, m_stream.c_str());
ASSERT_EQ(strlen(m_stream.c_str()), MEDIUM_STRING.length());
}
/// Send a long string test to an empty LogEntryStream. Expect that c_str() returns a matching string.
TEST_F(LogEntryStreamTest, longString) {
std::string longString;
for (int ix = 0; ix < 100; ix++) {
longString += "The quick brown fox jumped over the lazy dog.";
}
m_stream << longString;
ASSERT_EQ(longString, m_stream.c_str());
ASSERT_EQ(strlen(m_stream.c_str()), longString.length());
}
/// Send a few short strings. Expect that c_str() returns the concatenation of those strings.
TEST_F(LogEntryStreamTest, aFewStrings) {
const std::string SHORT_STRING_1 = "abc";
m_stream << SHORT_STRING_1;
const std::string SHORT_STRING_2 = "xyz";
m_stream << SHORT_STRING_2;
const std::string SHORT_STRING_3 = "123";
m_stream << SHORT_STRING_3;
auto expectedString = SHORT_STRING_1 + SHORT_STRING_2 + SHORT_STRING_3;
ASSERT_EQ(expectedString, m_stream.c_str());
ASSERT_EQ(strlen(m_stream.c_str()), expectedString.length());
}
/// Send a bunch of ints and strings. Expect that c_str() matches the result of sending the same to ostringstream.
TEST_F(LogEntryStreamTest, aLotOfStrings) {
std::ostringstream expected;
const std::string MEDIUM_STRING = "Half a bee, philosophically\nMust, ipso facto, half not be.";
for (int ix = 0; ix < 100; ix++) {
m_stream << ix << MEDIUM_STRING;
expected << ix << MEDIUM_STRING;
}
ASSERT_EQ(expected.str(), m_stream.c_str());
ASSERT_EQ(strlen(m_stream.c_str()), expected.str().length());
}
Version 1.1.0 alexa-client-sdk - Changes in this update: - Better GStreamer error reporting. MediaPlayer used to only report `MEDIA_ERROR_UNKNOWN`, now reports more specific errors as defined in `ErrorType.h`. - Codebase has been formatted for easier reading. - `DirectiveRouter::removeDirectiveHandler()` signature changed and now returns a bool indicating if given handler should be successfully removed or not. - Cleanup of raw and shared pointers in the creation of `Transport` objects. - `HTTP2Stream`s now have IDs assigned as they are acquired as opposed to created, making associated logs easier to interpret. - `AlertsCapabilityAgent` has been refactored. - Alert management has been factored out into an `AlertScheduler` class. - Creation of Reminder (implements Alert) class. - Added new capability agent for `PlaybackController` with unit tests. - Added Settings interface with unit tests. - Return type of `getOffsetInMilliseconds()` changed from `int64_t` to `std::chronology::milliseconds`. - Added `AudioPlayer` unit tests. - Added teardown for all Integration tests except Alerts. - Implemented PlaylistParser. - Bug fixes: - AIP getting stuck in `LISTENING` or `THINKING` and refusing user input on network outage. - SampleApp crashing if running for 5 minutes after network disconnect. - Issue where on repeated user barge-ins, `AudioPlayer` would not pause. Specifically, the third attempt to “Play iHeartRadio” would not result in currently-playing music pausing. - Utterances being ignored after particularly long TTS. - GStreamer errors cropping up on SampleApp exit as a result of accessing the pipeline before it’s been setup. - Crashing when playing one URL after another. - Buffer overrun in Alerts Renderer. - [SampleApp crashing when issuing "Alexa skip" command with iHeartRadio.](https://github.com/alexa/avs-device-sdk/issues/153) - [`HTTP2Transport` network thread triggering a join on itself.](https://github.com/alexa/avs-device-sdk/issues/127) - [`HTTP2Stream` request handling truncating exception messages.](https://github.com/alexa/avs-device-sdk/issues/67) - [`AudioPlayer` was attempting an incorrect state transition from `STOPPED` to `PLAYING` through a `playbackResumed`.](https://github.com/alexa/avs-device-sdk/issues/138)
2017-10-02 22:59:05 +00:00
} // namespace test
} // namespace logger
} // namespace utils
} // namespace avsCommon
} // namespace alexaClientSDK