OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
12 #include "content/browser/device_orientation/orientation.h" | 12 #include "content/browser/device_orientation/orientation.h" |
13 #include "content/browser/device_orientation/provider.h" | 13 #include "content/browser/device_orientation/provider.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 | 16 |
17 namespace device_orientation { | 17 namespace device_orientation { |
18 | 18 |
19 class MockProvider : public Provider { | 19 class MockProvider : public Provider { |
20 public: | 20 public: |
21 explicit MockProvider(const Orientation& orientation) | 21 explicit MockProvider(const Orientation& orientation) |
22 : orientation_(orientation), | 22 : orientation_(orientation), |
23 added_observer_(false), | 23 added_observer_(false), |
24 removed_observer_(false) {} | 24 removed_observer_(false) {} |
25 | 25 |
26 virtual void AddObserver(Observer* observer) { | 26 virtual void AddObserver(Observer* observer) { |
27 added_observer_ = true; | 27 added_observer_ = true; |
28 observer->OnOrientationUpdate(orientation_); | 28 observer->OnDeviceDataUpdate(&orientation_); |
29 } | 29 } |
30 virtual void RemoveObserver(Observer* observer) { | 30 virtual void RemoveObserver(Observer* observer) { |
31 removed_observer_ = true; | 31 removed_observer_ = true; |
32 } | 32 } |
33 | 33 |
34 Orientation orientation_; | 34 Orientation orientation_; |
35 bool added_observer_; | 35 bool added_observer_; |
36 bool removed_observer_; | 36 bool removed_observer_; |
37 | 37 |
38 private: | 38 private: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 2); | 71 2); |
72 | 72 |
73 // Check that the page got the event it expected and that the provider | 73 // Check that the page got the event it expected and that the provider |
74 // saw requests for adding and removing an observer. | 74 // saw requests for adding and removing an observer. |
75 EXPECT_EQ("pass", chrome::GetActiveWebContents(browser())->GetURL().ref()); | 75 EXPECT_EQ("pass", chrome::GetActiveWebContents(browser())->GetURL().ref()); |
76 EXPECT_TRUE(provider->added_observer_); | 76 EXPECT_TRUE(provider->added_observer_); |
77 EXPECT_TRUE(provider->removed_observer_); | 77 EXPECT_TRUE(provider->removed_observer_); |
78 } | 78 } |
79 | 79 |
80 } // namespace device_orientation | 80 } // namespace device_orientation |
OLD | NEW |