summaryrefslogtreecommitdiffstats
path: root/ui/gfx/skia_util_unittest.cc
diff options
context:
space:
mode:
authorrhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 17:05:49 +0000
committerrhashimoto@chromium.org <rhashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 17:05:49 +0000
commitd2ec9af2197d396716ae15da9f1e1d27e8877b4c (patch)
tree7161075c7477772cb572a826f996e2d232736e2a /ui/gfx/skia_util_unittest.cc
parent8227d054171e22971d3688b02d02d9ad548ff12f (diff)
downloadchromium_src-d2ec9af2197d396716ae15da9f1e1d27e8877b4c.zip
chromium_src-d2ec9af2197d396716ae15da9f1e1d27e8877b4c.tar.gz
chromium_src-d2ec9af2197d396716ae15da9f1e1d27e8877b4c.tar.bz2
Apply HIDE_PREFIX to Skia strings on linux without doubling underscores.
On linux, CanvasSkia::DrawStringInt() was removing ampersands (when HIDE_PREFIX flag was set) with gfx::RemoveWindowsStyleAccelerators(), which has the side effect of doubling underscores. This CL replaces the call with code that only strips ampersands (turning doubled ampersands into a single ampersand). BUG=chromium-os:15823 TEST=observe network menu with SSIDs containing underscores and ampersands Review URL: http://codereview.chromium.org/7170025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89845 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/skia_util_unittest.cc')
-rw-r--r--ui/gfx/skia_util_unittest.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/ui/gfx/skia_util_unittest.cc b/ui/gfx/skia_util_unittest.cc
new file mode 100644
index 0000000..a35628d
--- /dev/null
+++ b/ui/gfx/skia_util_unittest.cc
@@ -0,0 +1,42 @@
+// Copyright (c) 2011 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 "ui/gfx/skia_util.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+static const char kAcceleratorChar = '&';
+
+TEST(SkiaUtilTest, RemoveAcceleratorChar) {
+ EXPECT_TRUE(gfx::RemoveAcceleratorChar("", kAcceleratorChar).empty());
+ EXPECT_TRUE(gfx::RemoveAcceleratorChar("&", kAcceleratorChar).empty());
+ EXPECT_EQ(std::string("no accelerator"),
+ gfx::RemoveAcceleratorChar("no accelerator", kAcceleratorChar));
+ EXPECT_EQ(std::string("one accelerator"),
+ gfx::RemoveAcceleratorChar("&one accelerator", kAcceleratorChar));
+ EXPECT_EQ(std::string("one accelerator"),
+ gfx::RemoveAcceleratorChar("one &accelerator", kAcceleratorChar));
+ EXPECT_EQ(std::string("one_accelerator"),
+ gfx::RemoveAcceleratorChar("one_accelerator&", kAcceleratorChar));
+ EXPECT_EQ(std::string("two accelerators"),
+ gfx::RemoveAcceleratorChar("&two &accelerators", kAcceleratorChar));
+ EXPECT_EQ(std::string("two accelerators"),
+ gfx::RemoveAcceleratorChar("two &accelerators&", kAcceleratorChar));
+ EXPECT_EQ(std::string("two accelerators"),
+ gfx::RemoveAcceleratorChar("two& &accelerators", kAcceleratorChar));
+ EXPECT_EQ(std::string("&escaping"),
+ gfx::RemoveAcceleratorChar("&&escaping", kAcceleratorChar));
+ EXPECT_EQ(std::string("escap&ing"),
+ gfx::RemoveAcceleratorChar("escap&&ing", kAcceleratorChar));
+ EXPECT_EQ(std::string("escaping&"),
+ gfx::RemoveAcceleratorChar("escaping&&", kAcceleratorChar));
+ EXPECT_EQ(std::string("mix&ed"),
+ gfx::RemoveAcceleratorChar("&mix&&ed", kAcceleratorChar));
+ EXPECT_EQ(std::string("&mix&ed"),
+ gfx::RemoveAcceleratorChar("&&m&ix&&e&d&", kAcceleratorChar));
+ EXPECT_EQ(std::string("&m&ixed&"),
+ gfx::RemoveAcceleratorChar("&&m&&ix&ed&&", kAcceleratorChar));
+ EXPECT_EQ(std::string("m&ixed&"),
+ gfx::RemoveAcceleratorChar("&m&&ix&ed&&", kAcceleratorChar));
+}