aw_content_browser_client_unittest.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2018 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. #include "android_webview/browser/aw_content_browser_client.h"
  5. #include "android_webview/browser/aw_feature_list_creator.h"
  6. #include "base/task/thread_pool/thread_pool_instance.h"
  7. #include "base/test/task_environment.h"
  8. #include "mojo/core/embedder/embedder.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. namespace android_webview {
  11. class AwContentBrowserClientTest : public testing::Test {
  12. protected:
  13. void SetUp() override {
  14. mojo::core::Init();
  15. }
  16. };
  17. TEST_F(AwContentBrowserClientTest, DisableCreatingThreadPool) {
  18. AwFeatureListCreator aw_feature_list_creator;
  19. AwContentBrowserClient client(&aw_feature_list_creator);
  20. EXPECT_TRUE(client.CreateThreadPool("Hello"));
  21. EXPECT_TRUE(base::ThreadPoolInstance::Get());
  22. // Have to start the threed pool to shut it down, have to shut it down to
  23. // destroy it.
  24. base::ThreadPoolInstance::Get()->Start(
  25. base::ThreadPoolInstance::InitParams(1));
  26. base::ThreadPoolInstance::Get()->Shutdown();
  27. base::ThreadPoolInstance::Get()->JoinForTesting();
  28. base::ThreadPoolInstance::Set(nullptr);
  29. AwContentBrowserClient::DisableCreatingThreadPool();
  30. EXPECT_FALSE(client.CreateThreadPool("Hello"));
  31. EXPECT_FALSE(base::ThreadPoolInstance::Get());
  32. }
  33. } // namespace android_webview