| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" | 5 #include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace ime = ::chromeos::input_method; | 10 namespace ime = ::chromeos::input_method; |
| 11 | 11 |
| 12 // For EXPECT_TRUE calls below. The operator has to be in the global namespace. | 12 // For EXPECT_TRUE calls below. The operator has to be in the global namespace. |
| 13 static bool operator==( | 13 static bool operator==( |
| 14 const ime::VirtualKeyboard& lhs, const ime::VirtualKeyboard& rhs) { | 14 const ime::VirtualKeyboard& lhs, const ime::VirtualKeyboard& rhs) { |
| 15 return lhs.GetURLForLayout("") == rhs.GetURLForLayout(""); | 15 return lhs.GetURLForLayout("") == rhs.GetURLForLayout(""); |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 typedef std::multimap< | 20 typedef std::multimap< |
| 21 std::string, const ime::VirtualKeyboard*> LayoutToKeyboard; | 21 std::string, const ime::VirtualKeyboard*> LayoutToKeyboard; |
| 22 | 22 |
| 23 // Returns true if [start, end) and |urls| are equal sets. | 23 // Returns true if [start, end) and |urls| are equal sets. |
| 24 template <size_t L> bool CheckUrls(LayoutToKeyboard::const_iterator start, | 24 template <size_t L> bool CheckUrls(LayoutToKeyboard::const_iterator start, |
| 25 LayoutToKeyboard::const_iterator end, | 25 LayoutToKeyboard::const_iterator end, |
| 26 const char* (&urls)[L]) { | 26 const char* (&urls)[L]) { |
| 27 std::set<GURL> expected_url_set; | 27 std::set<GURL> expected_url_set; |
| 28 for (size_t i = 0; i < L; ++i) { | 28 for (size_t i = 0; i < L; ++i) { |
| 29 if (!expected_url_set.insert(GURL(urls[i])).second) { | 29 if (!expected_url_set.insert(GURL(urls[i])).second) { |
| 30 LOG(ERROR) << "Duplicated URL: " << urls[i]; | 30 DVLOG(1) << "Duplicated URL: " << urls[i]; |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 | 34 |
| 35 std::set<GURL> actual_url_set; | 35 std::set<GURL> actual_url_set; |
| 36 for (LayoutToKeyboard::const_iterator iter = start; iter != end; ++iter) { | 36 for (LayoutToKeyboard::const_iterator iter = start; iter != end; ++iter) { |
| 37 if (!actual_url_set.insert(iter->second->url()).second) { | 37 if (!actual_url_set.insert(iter->second->url()).second) { |
| 38 LOG(ERROR) << "Duplicated URL: " << iter->second->url().spec(); | 38 DVLOG(1) << "Duplicated URL: " << iter->second->url().spec(); |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 return expected_url_set == actual_url_set; | 43 return expected_url_set == actual_url_set; |
| 44 } | 44 } |
| 45 | 45 |
| 46 template <size_t L> | 46 template <size_t L> |
| 47 std::set<std::string> CreateLayoutSet(const char* (&layouts)[L]) { | 47 std::set<std::string> CreateLayoutSet(const char* (&layouts)[L]) { |
| 48 std::set<std::string> result; | 48 std::set<std::string> result; |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 { | 730 { |
| 731 static const char* urls[] = { "http://system2" }; | 731 static const char* urls[] = { "http://system2" }; |
| 732 range = result2.equal_range("z"); | 732 range = result2.equal_range("z"); |
| 733 EXPECT_TRUE(CheckUrls(range.first, range.second, urls)); | 733 EXPECT_TRUE(CheckUrls(range.first, range.second, urls)); |
| 734 } | 734 } |
| 735 EXPECT_EQ(0U, result2.count("Z")); | 735 EXPECT_EQ(0U, result2.count("Z")); |
| 736 } | 736 } |
| 737 | 737 |
| 738 } // namespace input_method | 738 } // namespace input_method |
| 739 } // namespace chromeos | 739 } // namespace chromeos |
| OLD | NEW |