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