forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sync] Fix crash when converting Notification to string
Also add test. BUG=142925 Review URL: https://chromiumcodereview.appspot.com/10831347 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152158 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
akalin@chromium.org
committed
Aug 17, 2012
1 parent
a8fa4ca
commit 27c263a
Showing
3 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <string> | ||
|
||
#include "base/string_util.h" | ||
#include "jingle/notifier/listener/notification_defines.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace notifier { | ||
namespace { | ||
|
||
class NotificationTest : public testing::Test {}; | ||
|
||
// Create a notification with binary data in the data field. | ||
// Converting it to string shouldn't cause a crash. | ||
TEST_F(NotificationTest, BinaryData) { | ||
const char kNonUtf8Data[] = { '\xff', '\0' }; | ||
EXPECT_FALSE(IsStringUTF8(kNonUtf8Data)); | ||
Notification notification; | ||
notification.data = kNonUtf8Data; | ||
EXPECT_EQ("{ channel: \"\", data: \"\\u00FF\" }", notification.ToString()); | ||
} | ||
|
||
} // namespace | ||
} // namespace notifier |