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 | |
24 // The path read from the registry can be quoted. To check for the existence | |
25 // of the file we use the base::PathExists function which internally uses the | |
26 // GetFileAttributes API which does not accept quoted strings. Our workaround | |
27 // is to look for quotes in the first and last position in the string and | |
28 // erase them. | |
29 if (osk_path.front() == L'"') { | |
sky
2016/05/24 21:41:26
You should check the size too (otherwise 31 may cr
ananta
2016/05/24 22:09:33
Added some more checks above this if which removes
| |
30 osk_path.erase(0, 1); // erase the first character. | |
31 osk_path.erase(osk_path.size() - 1); // erase the last character. | |
sky
2016/05/24 21:41:26
Can this be simplified to:
osk_path = osk_path.sub
ananta
2016/05/24 22:09:33
Done.
| |
32 } | |
33 | |
34 EXPECT_TRUE(base::PathExists(base::FilePath(osk_path))); | |
35 } | |
OLD | NEW |