summaryrefslogtreecommitdiffstats
path: root/chrome/test/remoting/fullscreen_browsertest.cc
blob: 40819cdc6ff1ad9ba20ddbf7b7461d615db45c3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2014 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 "base/files/file_path.h"
#include "base/files/file_util.h"
#include "chrome/test/remoting/remote_desktop_browsertest.h"
#include "chrome/test/remoting/waiter.h"

namespace remoting {

class FullscreenBrowserTest : public RemoteDesktopBrowserTest {
 protected:
  bool WaitForFullscreenChange(bool expect_fullscreen);
};

bool FullscreenBrowserTest::WaitForFullscreenChange(bool expect_fullscreen) {
  std::string javascript = expect_fullscreen ?
      "remoting.fullscreen.isActive()" :
      "!remoting.fullscreen.isActive()";
  ConditionalTimeoutWaiter waiter(
      base::TimeDelta::FromSeconds(20),
      base::TimeDelta::FromSeconds(1),
      base::Bind(&RemoteDesktopBrowserTest::IsHostActionComplete,
                 active_web_contents(),
                 javascript));
  bool result = waiter.Wait();
  // Entering or leaving full-screen mode causes local and remote desktop
  // reconfigurations that can take a while to settle down, so wait a few
  // seconds before continuing.
  TimeoutWaiter(base::TimeDelta::FromSeconds(10)).Wait();
  return result;
}

IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, MANUAL_Me2Me_Fullscreen) {
  SetUpTestForMe2Me();
  ConnectToLocalHost(false);

  // Verify that we're initially not full-screen.
  EXPECT_FALSE(ExecuteScriptAndExtractBool(
      "remoting.fullscreen.isActive()"));

  // Click the full-screen button and verify that it activates full-screen mode.
  ClickOnControl("toggle-full-screen");
  EXPECT_TRUE(WaitForFullscreenChange(true));

  // Click the full-screen button again and verify that it deactivates
  // full-screen mode.
  ClickOnControl("toggle-full-screen");
  EXPECT_TRUE(WaitForFullscreenChange(false));

  // Enter full-screen mode again, then disconnect and verify that full-screen
  // mode is deactivated upon disconnection.
  // TODO(jamiewalch): For the v2 app, activate full-screen mode indirectly by
  // maximizing the window for the second test.
  ClickOnControl("toggle-full-screen");
  EXPECT_TRUE(WaitForFullscreenChange(true));
  DisconnectMe2Me();
  EXPECT_TRUE(WaitForFullscreenChange(false));

  Cleanup();
}

IN_PROC_BROWSER_TEST_F(FullscreenBrowserTest, MANUAL_Me2Me_Bump_Scroll) {
  SetUpTestForMe2Me();

  content::WebContents* content = app_web_content();
  LoadScript(content, FILE_PATH_LITERAL("bump_scroll_browser_test.js"));

  RunJavaScriptTest(content, "Bump_Scroll", "{pin: '" + me2me_pin() + "'}");

  Cleanup();
}

}  // namespace remoting