OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/base/win/osk_display_manager.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" |
| 10 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 // This test validates the on screen keyboard path (tabtip.exe) which is read |
| 15 // from the registry. |
| 16 TEST(OnScreenKeyboardTest, OSKPath) { |
| 17 ui::OnScreenKeyboardDisplayManager* keyboard_display_manager = |
| 18 ui::OnScreenKeyboardDisplayManager::GetInstance(); |
| 19 EXPECT_NE(nullptr, keyboard_display_manager); |
| 20 |
| 21 base::string16 osk_path; |
| 22 EXPECT_TRUE(keyboard_display_manager->GetOSKPath(&osk_path)); |
| 23 EXPECT_FALSE(osk_path.empty()); |
| 24 EXPECT_TRUE(osk_path.find(L"tabtip.exe") != base::string16::npos); |
| 25 |
| 26 // The path read from the registry can be quoted. To check for the existence |
| 27 // of the file we use the base::PathExists function which internally uses the |
| 28 // GetFileAttributes API which does not accept quoted strings. Our workaround |
| 29 // is to look for quotes in the first and last position in the string and |
| 30 // erase them. |
| 31 if ((osk_path.front() == L'"') && (osk_path.back() == L'"')) |
| 32 osk_path = osk_path.substr(1, osk_path.size() - 2); |
| 33 |
| 34 EXPECT_TRUE(base::PathExists(base::FilePath(osk_path))); |
| 35 } |
OLD | NEW |