summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 17:24:04 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-14 17:24:04 +0000
commit878761aef2460c1c2b8922e3e4c5da234f5c7b60 (patch)
tree56773b33766fd514c5162cdf152e04ab536b61c3 /chrome
parent5c91bbc6ae963864ca27dd9fb6633dbf824cb2fd (diff)
downloadchromium_src-878761aef2460c1c2b8922e3e4c5da234f5c7b60.zip
chromium_src-878761aef2460c1c2b8922e3e4c5da234f5c7b60.tar.gz
chromium_src-878761aef2460c1c2b8922e3e4c5da234f5c7b60.tar.bz2
Wait for the GPU info to be collected.
BUG=59131 TEST=none Review URL: http://codereview.chromium.org/5698009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gpu_process_host_ui_shim.cc4
-rw-r--r--chrome/browser/gpu_process_host_ui_shim.h13
-rw-r--r--chrome/test/gpu/gpu_pixel_browsertest.cc55
3 files changed, 68 insertions, 4 deletions
diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc
index f864634..d6b7d6a 100644
--- a/chrome/browser/gpu_process_host_ui_shim.cc
+++ b/chrome/browser/gpu_process_host_ui_shim.cc
@@ -104,6 +104,10 @@ const GPUInfo& GpuProcessHostUIShim::gpu_info() const {
void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
gpu_info_ = gpu_info;
child_process_logging::SetGpuInfo(gpu_info);
+
+ // Used only in testing.
+ if (gpu_info_collected_callback_.get())
+ gpu_info_collected_callback_->Run();
}
void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
diff --git a/chrome/browser/gpu_process_host_ui_shim.h b/chrome/browser/gpu_process_host_ui_shim.h
index 8b09067..d0d0f37 100644
--- a/chrome/browser/gpu_process_host_ui_shim.h
+++ b/chrome/browser/gpu_process_host_ui_shim.h
@@ -11,7 +11,9 @@
// portion of this class, the GpuProcessHost, is responsible for
// shuttling messages between the browser and GPU processes.
+#include "base/callback.h"
#include "base/non_thread_safe.h"
+#include "base/scoped_ptr.h"
#include "base/singleton.h"
#include "chrome/common/gpu_info.h"
#include "chrome/common/message_router.h"
@@ -54,6 +56,13 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
// Return all known information about the GPU.
const GPUInfo& gpu_info() const;
+ // Used only in testing. Sets a callback to invoke when GPU info is collected,
+ // regardless of whether it has been collected already or if it is partial
+ // or complete info. Set to NULL when the callback should no longer be called.
+ void set_gpu_info_collected_callback(Callback0::Type* callback) {
+ gpu_info_collected_callback_.reset(callback);
+ }
+
private:
friend struct DefaultSingletonTraits<GpuProcessHostUIShim>;
@@ -70,6 +79,10 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
GPUInfo gpu_info_;
MessageRouter router_;
+
+ // Used only in testing. If set, the callback is invoked when the GPU info
+ // has been collected.
+ scoped_ptr<Callback0::Type> gpu_info_collected_callback_;
};
#endif // CHROME_BROWSER_GPU_PROCESS_HOST_UI_SHIM_H_
diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc
index e5c2238..e21da69 100644
--- a/chrome/test/gpu/gpu_pixel_browsertest.cc
+++ b/chrome/test/gpu/gpu_pixel_browsertest.cc
@@ -7,6 +7,7 @@
#include "app/app_switches.h"
#include "app/gfx/gl/gl_implementation.h"
+#include "base/callback.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -78,6 +79,51 @@ void ResizeTabContainer(Browser* browser, const gfx::Size& desired_size) {
browser->window()->SetBounds(window_rect);
}
+// Observes when any GPU info has been collected and quits the current message
+// loop.
+class GPUInfoCollectedObserver {
+ public:
+ explicit GPUInfoCollectedObserver(GpuProcessHostUIShim* gpu_host_shim)
+ : gpu_host_shim_(gpu_host_shim),
+ gpu_info_collected_(false) {
+ gpu_host_shim_->set_gpu_info_collected_callback(
+ NewCallback(this, &GPUInfoCollectedObserver::OnGpuInfoCollected));
+ }
+
+ void OnGpuInfoCollected() {
+ gpu_info_collected_ = true;
+ gpu_host_shim_->set_gpu_info_collected_callback(NULL);
+ MessageLoopForUI::current()->Quit();
+ }
+
+ bool gpu_info_collected() { return gpu_info_collected_; }
+
+ private:
+ GpuProcessHostUIShim* gpu_host_shim_;
+ bool gpu_info_collected_;
+};
+
+// Collects info about the GPU. Iff the info is collected, |client_info| will be
+// set and true will be returned. This info may be partial or complete. This
+// will return false if we are running in a virtualized environment.
+bool CollectGPUInfo(GPUInfo* client_info) {
+ CHECK(client_info);
+ GpuProcessHostUIShim* gpu_host_shim = GpuProcessHostUIShim::GetInstance();
+ if (!gpu_host_shim)
+ return false;
+ GPUInfo info = gpu_host_shim->gpu_info();
+ if (info.progress() == GPUInfo::kUninitialized) {
+ GPUInfoCollectedObserver observer(gpu_host_shim);
+ gpu_host_shim->CollectGraphicsInfoAsynchronously();
+ ui_test_utils::RunMessageLoop();
+ if (!observer.gpu_info_collected())
+ return false;
+ info = gpu_host_shim->gpu_info();
+ }
+ *client_info = info;
+ return true;
+}
+
} // namespace
// Test fixture for GPU image comparison tests.
@@ -156,15 +202,16 @@ class GpuPixelBrowserTest : public InProcessBrowserTest {
#error "Not implemented for this platform"
#endif
if (using_gpu_) {
- const GPUInfo& info = GpuProcessHostUIShim::GetInstance()->gpu_info();
- if (info.progress() != GPUInfo::kComplete) {
+ GPUInfo info;
+ if (!CollectGPUInfo(&info)) {
LOG(ERROR) << "Could not get gpu info";
return false;
}
- img_name = StringPrintf("%s_%s_%x-%x.png",
+ img_name = base::StringPrintf("%s_%s_%04x-%04x.png",
img_name.c_str(), os_label, info.vendor_id(), info.device_id());
} else {
- img_name = StringPrintf("%s_%s_mesa.png", img_name.c_str(), os_label);
+ img_name = base::StringPrintf("%s_%s_mesa.png",
+ img_name.c_str(), os_label);
}
// Read the reference image and verify the images' dimensions are equal.