chromium/components/input/test/input_browsertest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/test/scoped_feature_list.h"
#include "base/test/test_trace_processor.h"
#include "components/input/features.h"
#include "components/input/utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"

namespace input {

class InputBrowserTest : public content::ContentBrowserTest {};

#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(InputBrowserTest,
                       RenderInputRouterNotCreatedOnNonAndroid) {}
#else
class AndroidInputBrowserTest : public InputBrowserTest,
                                public ::testing::WithParamInterface<bool> {
 public:
  AndroidInputBrowserTest() {
    scoped_feature_list_.InitWithFeatureState(features::kInputOnViz,
                                              /* enabled= */ GetParam());
  }

 private:
  base::test::ScopedFeatureList scoped_feature_list_;
};

IN_PROC_BROWSER_TEST_P(AndroidInputBrowserTest, RenderInputRouterCreation) {
  const bool expected_creation = TransferInputToViz() ? true : false;
  EXPECT_EQ(IsRenderInputRouterCreatedOnViz(), expected_creation);
}

INSTANTIATE_TEST_SUITE_P(All,
                         AndroidInputBrowserTest,
                         ::testing::Bool(),
                         [](auto& info) {
                           return info.param ? "InputOnViz_Enabled"
                                             : "InputOnViz_Disabled";
                         });
#endif  // !BUILDFLAG(IS_ANDROID)

}  // namespace input