Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7927)

Unified Diff: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc

Issue 2833773005: Pause drawing webvr when the App button is pressed (Closed)
Patch Set: refactor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc
diff --git a/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..971d869731358cf12032b9bf5c2158a88856b9a4
--- /dev/null
+++ b/chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc
@@ -0,0 +1,56 @@
+// 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/android/vr_shell/ui_scene_manager.h"
+
+#include "base/macros.h"
+#include "chrome/browser/android/vr_shell/ui_scene.h"
+#include "chrome/browser/android/vr_shell/vr_browser_interface.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace vr_shell {
+
+namespace {
+
+class MockBrowserInterface : public VrBrowserInterface {
+ public:
+ MockBrowserInterface() : weak_ptr_factory_(this) {}
+ ~MockBrowserInterface() override {}
+
+ base::WeakPtr<VrBrowserInterface> GetWeakPtr() {
+ return weak_ptr_factory_.GetWeakPtr();
+ }
+
+ MOCK_METHOD1(OnContentPaused, void(bool));
+
+ private:
+ base::WeakPtrFactory<VrBrowserInterface> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockBrowserInterface);
+};
+
+} // namespace
+
+class UiSceneManagerTest : public testing::Test {
cjgrant 2017/05/02 18:07:06 This looks awesome now IMO. Thanks!
ymalik 2017/05/02 20:28:40 Acknowledged.
+ public:
+ void SetUp() override {
+ browser_ = base::MakeUnique<MockBrowserInterface>();
+ scene_ = base::MakeUnique<UiScene>();
+ manager_ =
+ base::MakeUnique<UiSceneManager>(browser_->GetWeakPtr(), scene_.get());
+ }
+
+ protected:
+ std::unique_ptr<MockBrowserInterface> browser_;
+ std::unique_ptr<UiScene> scene_;
+ std::unique_ptr<UiSceneManager> manager_;
+};
+
+TEST_F(UiSceneManagerTest, AppButtonPressed) {
cjgrant 2017/05/02 18:07:06 "Pressed" sounds like "pressed and held". "Clicke
cjgrant 2017/05/02 18:07:06 I think style prefers verbose test names that desc
ymalik 2017/05/02 20:28:40 Done. Renamed OnAppButtonPressed to OnAppButtonCli
+ EXPECT_CALL(*browser_, OnContentPaused(true)).Times(1);
+ manager_->AppButtonPressed();
cjgrant 2017/05/02 18:07:06 Should you check that the scene is also now report
cjgrant 2017/05/02 18:07:06 Why not also check that another click unpaused con
ymalik 2017/05/02 20:28:40 Totally!
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698