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

Unified Diff: blimp/engine/browser_tests/blimp_contents_view_readback_helper.h

Issue 2320923002: Add a full Blimp integration test. (Closed)
Patch Set: Fix build break with chrome embedder Created 4 years, 3 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: blimp/engine/browser_tests/blimp_contents_view_readback_helper.h
diff --git a/blimp/engine/browser_tests/blimp_contents_view_readback_helper.h b/blimp/engine/browser_tests/blimp_contents_view_readback_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..455f5ac5da019100722d13d4bb56e4c84bd24a19
--- /dev/null
+++ b/blimp/engine/browser_tests/blimp_contents_view_readback_helper.h
@@ -0,0 +1,49 @@
+// Copyright 2016 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.
+
+#ifndef BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_
+#define BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/synchronization/waitable_event.h"
+#include "blimp/client/public/contents/blimp_contents_view.h"
+
+namespace blimp {
+
+// A helper class to make grabbing a bitmap from a BlimpContentsView easier.
+// This can be used in conjunction with a WaitableContentPump to pause test
+// execution while waiting for the readback to finish. An example use would be:
+//
+// WaitableContentPump pump;
+// BlimpContentsViewReadbackHelper helper;
+// blimp_contents->GetView()->CopyCompositingSurface(
+// helper.GetCallback(), true);
+// pump.WaitFor(helper.event());
+// helper.bitmap();
+
+class BlimpContentsViewReadbackHelper {
+ public:
+ BlimpContentsViewReadbackHelper();
+ virtual ~BlimpContentsViewReadbackHelper();
+
+ client::BlimpContentsView::ReadbackRequestCallback GetCallback();
+ SkBitmap* GetBitmap() const;
+
+ base::WaitableEvent* event() { return &event_; }
+
+ private:
+ void OnReadbackComplete(std::unique_ptr<SkBitmap> bitmap);
+
+ base::WaitableEvent event_;
+ std::unique_ptr<SkBitmap> bitmap_;
+
+ base::WeakPtrFactory<BlimpContentsViewReadbackHelper> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpContentsViewReadbackHelper);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_
« no previous file with comments | « blimp/engine/browser_tests/blimp_browser_test.cc ('k') | blimp/engine/browser_tests/blimp_contents_view_readback_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698