summaryrefslogtreecommitdiff
path: root/chromium/content/browser/gpu/gpu_crash_browsertest.cc
blob: eafbc689cd0bb566d1a81d11cb7a89c66f7b46cf (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
// Copyright (c) 2012 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/path_service.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/common/content_paths.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "content/shell/shell.h"
#include "content/test/content_browser_test.h"
#include "content/test/content_browser_test_utils.h"

namespace content {
class GpuCrashTest : public ContentBrowserTest {
 protected:
  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
    base::FilePath test_dir;
    ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &test_dir));
    gpu_test_dir_ = test_dir.AppendASCII("gpu");
  }
  base::FilePath gpu_test_dir_;
};

#if defined(OS_LINUX) && !defined(NDEBUG)
// http://crbug.com/254724
#define IF_NOT_DEBUG_LINUX(x) DISABLED_ ## x
#else
#define IF_NOT_DEBUG_LINUX(x) x
#endif

IN_PROC_BROWSER_TEST_F(GpuCrashTest, IF_NOT_DEBUG_LINUX(MANUAL_Kill)) {
  DOMMessageQueue message_queue;

  content::GpuDataManagerImpl::GetInstance()->
      DisableDomainBlockingFor3DAPIsForTesting();

  // Load page and wait for it to load.
  content::WindowedNotificationObserver observer(
      content::NOTIFICATION_LOAD_STOP,
      content::NotificationService::AllSources());
  NavigateToURL(
      shell(),
      GetFileUrlWithQuery(
          gpu_test_dir_.AppendASCII("webgl.html"), "query=kill"));
  observer.Wait();

  GpuProcessHostUIShim* host =
      GpuProcessHostUIShim::GetOneInstance();
  ASSERT_TRUE(host);
  host->SimulateCrash();

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

IN_PROC_BROWSER_TEST_F(GpuCrashTest,
                       IF_NOT_DEBUG_LINUX(MANUAL_WebkitLoseContext)) {
  DOMMessageQueue message_queue;

  NavigateToURL(
      shell(),
      GetFileUrlWithQuery(
          gpu_test_dir_.AppendASCII("webgl.html"),
          "query=WEBGL_lose_context"));

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

} // namespace content