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

Unified Diff: content/browser/device_orientation/device_orientation_browsertest.cc

Issue 10755002: Refactors DeviceOrientation to make it more extensible (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Handles null device_data in observer Created 8 years, 5 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: content/browser/device_orientation/device_orientation_browsertest.cc
diff --git a/content/browser/device_orientation/device_orientation_browsertest.cc b/content/browser/device_orientation/device_orientation_browsertest.cc
index 346d59206b1440ce8adf3ca3e08ad09fea85b8c7..373680d17a34e5a947250c7c4023c9cebd35791c 100644
--- a/content/browser/device_orientation/device_orientation_browsertest.cc
+++ b/content/browser/device_orientation/device_orientation_browsertest.cc
@@ -5,10 +5,12 @@
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/device_orientation/device_data.h"
#include "content/browser/device_orientation/orientation.h"
#include "content/browser/device_orientation/provider.h"
#include "content/public/browser/web_contents.h"
@@ -18,20 +20,24 @@ namespace device_orientation {
class MockProvider : public Provider {
public:
- explicit MockProvider(const Orientation& orientation)
- : orientation_(orientation),
+ explicit MockProvider(const Orientation* orientation,
hans 2012/07/18 17:21:02 no need for explicit here
aousterh 2012/07/20 11:18:52 Done. Also changed orientation->device data so tha
+ DeviceData::Type device_data_type)
+ : device_data_type_(device_data_type),
added_observer_(false),
- removed_observer_(false) {}
+ removed_observer_(false) {
+ orientation_.reset(orientation);
+ }
virtual void AddObserver(Observer* observer) {
added_observer_ = true;
- observer->OnOrientationUpdate(orientation_);
+ observer->OnDeviceDataUpdate(orientation_.get(), device_data_type_);
}
virtual void RemoveObserver(Observer* observer) {
removed_observer_ = true;
}
- Orientation orientation_;
+ scoped_ptr<const Orientation> orientation_;
aousterh 2012/07/20 11:18:52 Changing this to device_data_ instead of orientati
+ DeviceData::Type device_data_type_;
bool added_observer_;
bool removed_observer_;
@@ -54,12 +60,13 @@ class DeviceOrientationBrowserTest : public InProcessBrowserTest {
// crbug.com/113952
IN_PROC_BROWSER_TEST_F(DeviceOrientationBrowserTest, BasicTest) {
- Orientation test_orientation;
- test_orientation.set_alpha(1);
- test_orientation.set_beta(2);
- test_orientation.set_gamma(3);
- test_orientation.set_absolute(true);
- scoped_refptr<MockProvider> provider(new MockProvider(test_orientation));
+ scoped_ptr<Orientation> test_orientation(new Orientation());
+ test_orientation->set_alpha(1);
+ test_orientation->set_beta(2);
+ test_orientation->set_gamma(3);
+ test_orientation->set_absolute(true);
+ scoped_refptr<MockProvider> provider(new MockProvider(
+ test_orientation.release(), DeviceData::kTypeOrientation));
Provider::SetInstanceForTests(provider.get());
// The test page will register an event handler for orientation events,

Powered by Google App Engine
This is Rietveld 408576698