// 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 "ui/gfx/linux_util.h"

#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gfx {

TEST(LinuxUtilTest, ConvertAcceleratorsFromWindowsStyle) {
  static const struct {
    const char* input;
    const char* output;
  } cases[] = {
    { "", "" },
    { "nothing", "nothing" },
    { "foo &bar", "foo _bar" },
    { "foo &&bar", "foo &bar" },
    { "foo &&&bar", "foo &_bar" },
    { "&foo &&bar", "_foo &bar" },
    { "&foo &bar", "_foo _bar" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
    std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input);
    EXPECT_EQ(cases[i].output, result);
  }
}

TEST(LinuxUtilTest, RemoveWindowsStyleAccelerators) {
  static const struct {
    const char* input;
    const char* output;
  } cases[] = {
    { "", "" },
    { "nothing", "nothing" },
    { "foo &bar", "foo bar" },
    { "foo &&bar", "foo &bar" },
    { "foo &&&bar", "foo &bar" },
    { "&foo &&bar", "foo &bar" },
    { "&foo &bar", "foo bar" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
    std::string result = RemoveWindowsStyleAccelerators(cases[i].input);
    EXPECT_EQ(cases[i].output, result);
  }
}

}  // namespace gfx

// 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 "ui/gfx/linux_util.h"

#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace gfx {

TEST(LinuxUtilTest, ConvertAcceleratorsFromWindowsStyle) {
  static const struct {
    const char* input;
    const char* output;
  } cases[] = {
    { "", "" },
    { "nothing", "nothing" },
    { "foo &bar", "foo _bar" },
    { "foo &&bar", "foo &bar" },
    { "foo &&&bar", "foo &_bar" },
    { "&foo &&bar", "_foo &bar" },
    { "&foo &bar", "_foo _bar" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
    std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input);
    EXPECT_EQ(cases[i].output, result);
  }
}

}  // namespace gfx

--- 
+++ 
@@ -28,4 +28,23 @@
   }
 }
 
+TEST(LinuxUtilTest, RemoveWindowsStyleAccelerators) {
+  static const struct {
+    const char* input;
+    const char* output;
+  } cases[] = {
+    { "", "" },
+    { "nothing", "nothing" },
+    { "foo &bar", "foo bar" },
+    { "foo &&bar", "foo &bar" },
+    { "foo &&&bar", "foo &bar" },
+    { "&foo &&bar", "foo &bar" },
+    { "&foo &bar", "foo bar" },
+  };
+  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
+    std::string result = RemoveWindowsStyleAccelerators(cases[i].input);
+    EXPECT_EQ(cases[i].output, result);
+  }
+}
+
 }  // namespace gfx
ui/gfx: Add unittests for RemoveWindowsStyleAccelerators() function.

TEST=ui_unittests --gtest_filter=LinuxUtilTest*
R=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9662039

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@126284 0039d316-1c4b-4281-b951-d872f2087c98
