Chromium Code Reviews| Index: ui/base/win/osk_display_manager_unittest.cc |
| diff --git a/ui/base/win/osk_display_manager_unittest.cc b/ui/base/win/osk_display_manager_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dcab36f8df50802d20e1415e0c5b56f0e16e66b6 |
| --- /dev/null |
| +++ b/ui/base/win/osk_display_manager_unittest.cc |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2016 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/base/win/osk_display_manager.h" |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/files/file_util.h" |
| +#include "base/logging.h" |
| +#include "base/macros.h" |
| +#include "base/strings/string16.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +// This test validates the on screen keyboard path (TabTip.exe) which is read |
| +// from the registry. |
| +TEST(OnScreenKeyboardTest, OSKPath) { |
| + ui::OnScreenKeyboardDisplayManager* keyboard_display_manager = |
| + ui::OnScreenKeyboardDisplayManager::GetInstance(); |
| + EXPECT_NE(nullptr, keyboard_display_manager); |
| + |
| + base::string16 osk_path; |
| + EXPECT_TRUE(keyboard_display_manager->GetOSKPath(&osk_path)); |
| + |
| + // The path read from the registry can be quoted. To check for the existence |
| + // of the file we use the base::PathExists function which internally uses the |
| + // GetFileAttributes API which does not accept quoted strings. Our workaround |
| + // is to look for quotes in the first and last position in the string and |
| + // erase them. |
| + 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
|
| + osk_path.erase(0, 1); // erase the first character. |
| + 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.
|
| + } |
| + |
| + EXPECT_TRUE(base::PathExists(base::FilePath(osk_path))); |
| +} |