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

84 lines
2.3 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 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 <string>
#include <ctime>
#include <gtest/gtest.h>
#include "AVSCommon/Utils/Timing/TimeUtils.h"
namespace alexaClientSDK {
namespace avsCommon {
namespace utils {
namespace timing {
namespace test {
TEST(TimeTest, testStringConversion) {
std::string dateStr{"1986-08-10T21:30:00+0000"};
int64_t date;
auto success = convert8601TimeStringToUnix(dateStr, &date);
ASSERT_TRUE(success);
auto dateTimeT = static_cast<time_t>(date);
auto dateTm = std::gmtime(&dateTimeT);
ASSERT_EQ(dateTm->tm_year, 86);
ASSERT_EQ(dateTm->tm_mon, 7);
ASSERT_EQ(dateTm->tm_mday, 10);
ASSERT_EQ(dateTm->tm_hour, 21);
ASSERT_EQ(dateTm->tm_min, 30);
}
TEST(TimeTest, testStringConversionError) {
std::string dateStr{"1986-8-10T21:30:00+0000"};
int64_t date;
auto success = convert8601TimeStringToUnix(dateStr, &date);
ASSERT_FALSE(success);
}
TEST(TimeTest, testStringConversionNullParam) {
std::string dateStr{"1986-8-10T21:30:00+0000"};
auto success = convert8601TimeStringToUnix(dateStr, nullptr);
ASSERT_FALSE(success);
}
TEST(TimeTest, testTimeConversion) {
std::time_t randomDate = 524089800;
auto date = std::gmtime(&randomDate);
std::time_t convertBack;
auto success = convertToUtcTimeT(date, &convertBack);
ASSERT_TRUE(success);
ASSERT_EQ(randomDate, convertBack);
}
TEST(TimeTest, testCurrentTime) {
int64_t time = -1;
auto success = getCurrentUnixTime(&time);
ASSERT_TRUE(success);
ASSERT_GT(time, 0);
}
TEST(TimeTest, testCurrentTimeNullParam) {
auto success = getCurrentUnixTime(nullptr);
ASSERT_FALSE(success);
}
} // namespace test
} // namespace timing
} // namespace utils
} // namespace avsCommon
} // namespace alexaClientSDK