chromoting_host_context_unittest.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2012 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 "remoting/host/chromoting_host_context.h"
  5. #include "base/run_loop.h"
  6. #include "base/test/task_environment.h"
  7. #include "remoting/base/auto_thread_task_runner.h"
  8. #include "testing/gtest/include/gtest/gtest.h"
  9. namespace remoting {
  10. // A simple test that starts and stop the context. This tests the context
  11. // operates properly and all threads and message loops are valid.
  12. TEST(ChromotingHostContextTest, StartAndStop) {
  13. base::test::SingleThreadTaskEnvironment task_environment{
  14. base::test::SingleThreadTaskEnvironment::MainThreadType::UI};
  15. base::RunLoop run_loop;
  16. std::unique_ptr<ChromotingHostContext> context =
  17. ChromotingHostContext::Create(new AutoThreadTaskRunner(
  18. task_environment.GetMainThreadTaskRunner(), run_loop.QuitClosure()));
  19. EXPECT_TRUE(context);
  20. if (!context)
  21. return;
  22. EXPECT_TRUE(context->audio_task_runner().get());
  23. EXPECT_TRUE(context->video_capture_task_runner().get());
  24. EXPECT_TRUE(context->video_encode_task_runner().get());
  25. EXPECT_TRUE(context->file_task_runner().get());
  26. EXPECT_TRUE(context->input_task_runner().get());
  27. EXPECT_TRUE(context->network_task_runner().get());
  28. EXPECT_TRUE(context->ui_task_runner().get());
  29. context.reset();
  30. run_loop.Run();
  31. }
  32. } // namespace remoting