diff options
author | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 06:59:20 +0000 |
---|---|---|
committer | yusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 06:59:20 +0000 |
commit | 86bb87e4fdb5bf9e2188b77dbb2fe19bd7c757fe (patch) | |
tree | 0e03c49bb2aca4032f9e34a10b680cb8e764defd | |
parent | 60673ad7d0c0ef8bf3c81f7267b148c3a63c2c4a (diff) | |
download | chromium_src-86bb87e4fdb5bf9e2188b77dbb2fe19bd7c757fe.zip chromium_src-86bb87e4fdb5bf9e2188b77dbb2fe19bd7c757fe.tar.gz chromium_src-86bb87e4fdb5bf9e2188b77dbb2fe19bd7c757fe.tar.bz2 |
Add a test which detects duplicate entries in ash::kAcceleratorData[].
This is Ash version of chrome/browser/ui/views/accelerator_table_unittest.cc.
BUG=123856
TEST=ran the new test
Review URL: http://codereview.chromium.org/10261024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134875 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/accelerators/accelerator_table_unittest.cc | 44 | ||||
-rw-r--r-- | ash/ash.gyp | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/ash/accelerators/accelerator_table_unittest.cc b/ash/accelerators/accelerator_table_unittest.cc new file mode 100644 index 0000000..07d7816 --- /dev/null +++ b/ash/accelerators/accelerator_table_unittest.cc @@ -0,0 +1,44 @@ +// 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 <set> + +#include "base/basictypes.h" +#include "ash/accelerators/accelerator_table.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace ash { + +namespace { + +struct Cmp { + bool operator()(const AcceleratorData& lhs, + const AcceleratorData& rhs) { + if (lhs.trigger_on_press != rhs.trigger_on_press) + return lhs.trigger_on_press < rhs.trigger_on_press; + if (lhs.keycode != rhs.keycode) + return lhs.keycode < rhs.keycode; + if (lhs.shift != rhs.shift) + return lhs.shift < rhs.shift; + if (lhs.ctrl != rhs.ctrl) + return lhs.ctrl < rhs.ctrl; + return lhs.alt < rhs.alt; + // Do not check |action|. + } +}; + +} // namespace + +TEST(AcceleratorTableTest, CheckDuplicatedAccelerators) { + std::set<AcceleratorData, Cmp> acclerators; + for (size_t i = 0; i < kAcceleratorDataLength; ++i) { + const AcceleratorData& entry = kAcceleratorData[i]; + EXPECT_TRUE(acclerators.insert(entry).second) + << "Duplicated accelerator: " << entry.trigger_on_press << ", " + << entry.keycode << ", " << entry.shift << ", " << entry.ctrl << ", " + << entry.alt; + } +} + +} // namespace ash diff --git a/ash/ash.gyp b/ash/ash.gyp index d89e543..47e6b8a 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -344,6 +344,7 @@ '../ui/views/test/test_views_delegate.h', 'accelerators/accelerator_controller_unittest.cc', 'accelerators/accelerator_filter_unittest.cc', + 'accelerators/accelerator_table_unittest.cc', 'accelerators/nested_dispatcher_controller_unittest.cc', 'app_list/app_list_unittest.cc', 'dip_unittest.cc', |