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
11namespace notifier {
12namespace {
13
14class 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.
18TEST_F(NotificationTest, BinaryData) {
19  const char kNonUtf8Data[] = { '\xff', '\0' };
20  EXPECT_FALSE(base::IsStringUTF8(kNonUtf8Data));
21  Notification notification;
22  notification.data = kNonUtf8Data;
23  EXPECT_EQ("{ channel: \"\", data: \"\\u00FF\" }", notification.ToString());
24}
25
26}  // namespace
27}  // namespace notifier
28