summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gpu_crash_browsertest.cc
blob: 671a7915a3dddd887a604a6e6204ca0bdc5ef7ae (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
76
77
78
79
80
81
82
83
// Copyright (c) 2011 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/command_line.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_launcher_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/gl/gl_implementation.h"

namespace {

void SimulateGPUCrash(Browser* browser) {
  LOG(ERROR) << "SimulateGPUCrash, before NavigateToURLWithDisposition";
  ui_test_utils::NavigateToURLWithDisposition(browser,
      GURL(chrome::kChromeUIGpuCrashURL), NEW_FOREGROUND_TAB,
      ui_test_utils::BROWSER_TEST_NONE);
  browser->SelectPreviousTab();
  LOG(ERROR) << "SimulateGPUCrash, after CloseTab";
}

} // namespace

class GPUCrashTest : public InProcessBrowserTest {
 protected:
  virtual void SetUpCommandLine(CommandLine* command_line) {
    EnableDOMAutomation();
    InProcessBrowserTest::SetUpCommandLine(command_line);

    // GPU tests require gpu acceleration.
    // We do not care which GL backend is used.
    command_line->AppendSwitchASCII(switches::kUseGL, "any");
  }
  virtual void SetUpInProcessBrowserTestFixture() {
    FilePath test_dir;
    ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
    gpu_test_dir_ = test_dir.AppendASCII("gpu");
  }
  FilePath gpu_test_dir_;
};

// Currently Kill timeout on GPU Debug bots: http://crbug.com/101513
#if !defined(NDEBUG)
#define MAYBE_Kill DISABLED_Kill
#else
#define MAYBE_Kill Kill
#endif
IN_PROC_BROWSER_TEST_F(GPUCrashTest, MAYBE_Kill) {
  ui_test_utils::DOMMessageQueue message_queue;

  ui_test_utils::NavigateToURL(
      browser(),
      ui_test_utils::GetFileUrlWithQuery(
          gpu_test_dir_.AppendASCII("webgl.html"), "query=kill"));
  SimulateGPUCrash(browser());

  std::string m;
  ASSERT_TRUE(message_queue.WaitForMessage(&m));
  EXPECT_EQ("\"SUCCESS\"", m);
}


IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) {
  ui_test_utils::DOMMessageQueue message_queue;

  ui_test_utils::NavigateToURL(
      browser(),
      ui_test_utils::GetFileUrlWithQuery(
          gpu_test_dir_.AppendASCII("webgl.html"),
          "query=WEBKIT_lose_context"));

  std::string m;
  ASSERT_TRUE(message_queue.WaitForMessage(&m));
  EXPECT_EQ("\"SUCCESS\"", m);
}