This source file includes following definitions.
- GetURL
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
#include "base/files/file_path.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
namespace {
const char kSimple[] = "simple.html";
GURL GetURL(const std::string& filename) {
return ui_test_utils::GetTestUrl(base::FilePath().AppendASCII("find_in_page"),
base::FilePath().AppendASCII(filename));
}
class FindBarControllerTest : public InProcessBrowserTest {
public:
FindBarControllerTest() {
chrome::DisableFindBarAnimationsDuringTesting(true);
}
};
IN_PROC_BROWSER_TEST_F(FindBarControllerTest, AcceleratorRestoring) {
ui_test_utils::NavigateToURL(browser(), GetURL(kSimple));
gfx::NativeWindow window = browser()->window()->GetNativeWindow();
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
views::FocusManager* focus_manager = widget->GetFocusManager();
ui::Accelerator escape(ui::VKEY_ESCAPE, ui::EF_NONE);
ui::AcceleratorTarget* old_target =
focus_manager->GetCurrentTargetForAccelerator(escape);
EXPECT_TRUE(old_target != NULL);
chrome::ShowFindBar(browser());
ui::AcceleratorTarget* new_target =
focus_manager->GetCurrentTargetForAccelerator(escape);
EXPECT_TRUE(new_target != NULL);
EXPECT_NE(new_target, old_target);
browser()->GetFindBarController()->EndFindSession(
FindBarController::kKeepSelectionOnPage,
FindBarController::kKeepResultsInFindBox);
EXPECT_EQ(old_target,
focus_manager->GetCurrentTargetForAccelerator(escape));
chrome::DisableFindBarAnimationsDuringTesting(false);
chrome::ShowFindBar(browser());
EXPECT_EQ(new_target,
focus_manager->GetCurrentTargetForAccelerator(escape));
}
}