blob: 40bf6ea51cc73bde6a3d5647bd3dc965b88c5dae [file] [log] [blame]
// Copyright 2017 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 "chrome/browser/ui/test/test_browser_ui.h"
#include "base/command_line.h"
#include "base/test/gtest_util.h"
#include "base/test/test_switches.h"
#include "build/build_config.h"
namespace {
// Extracts the |name| argument for ShowUi() from the current test case name.
// E.g. for InvokeUi_name (or DISABLED_InvokeUi_name) returns "name".
std::string NameFromTestCase() {
const std::string name = base::TestNameWithoutDisabledPrefix(
testing::UnitTest::GetInstance()->current_test_info()->name());
size_t underscore = name.find('_');
return underscore == std::string::npos ? std::string()
: name.substr(underscore + 1);
}
} // namespace
TestBrowserUi::TestBrowserUi() = default;
TestBrowserUi::~TestBrowserUi() = default;
void TestBrowserUi::ShowAndVerifyUi() {
PreShow();
ShowUi(NameFromTestCase());
ASSERT_TRUE(VerifyUi());
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kTestLauncherInteractive))
WaitForUserDismissal();
else
DismissUi();
}