1424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// found in the LICENSE file. 4424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 5424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include <string> 6424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/strings/string_util.h" 8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "jingle/notifier/listener/notification_defines.h" 9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 10424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 11424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace notifier { 12424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace { 13424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 14424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class NotificationTest : public testing::Test {}; 15424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Create a notification with binary data in the data field. 17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Converting it to string shouldn't cause a crash. 18424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)TEST_F(NotificationTest, BinaryData) { 19424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const char kNonUtf8Data[] = { '\xff', '\0' }; 20424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_FALSE(base::IsStringUTF8(kNonUtf8Data)); 21424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) Notification notification; 22424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) notification.data = kNonUtf8Data; 23424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) EXPECT_EQ("{ channel: \"\", data: \"\\u00FF\" }", notification.ToString()); 24424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 25424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 26424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} // namespace 27424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} // namespace notifier 28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)