389f3ccdf7a66b60b6a102a8c5ecd15f457f7c43
[platform/framework/web/crosswalk.git] / src / jingle / notifier / listener / notification_defines_unittest.cc
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/strings/string_util.h"
8 #include "jingle/notifier/listener/notification_defines.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace notifier {
12 namespace {
13
14 class NotificationTest : public testing::Test {};
15
16 // Create a notification with binary data in the data field.
17 // Converting it to string shouldn't cause a crash.
18 TEST_F(NotificationTest, BinaryData) {
19   const char kNonUtf8Data[] = { '\xff', '\0' };
20   EXPECT_FALSE(IsStringUTF8(kNonUtf8Data));
21   Notification notification;
22   notification.data = kNonUtf8Data;
23   EXPECT_EQ("{ channel: \"\", data: \"\\u00FF\" }", notification.ToString());
24 }
25
26 }  // namespace
27 }  // namespace notifier