| 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 EXPECT_TRUE([view->cocoa_view() isOpaque]); | 840 EXPECT_TRUE([view->cocoa_view() isOpaque]); |
| 841 | 841 |
| 842 view->SetBackgroundColor(SK_ColorTRANSPARENT); | 842 view->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 843 EXPECT_FALSE(view->GetBackgroundOpaque()); | 843 EXPECT_FALSE(view->GetBackgroundOpaque()); |
| 844 EXPECT_FALSE([view->cocoa_view() isOpaque]); | 844 EXPECT_FALSE([view->cocoa_view() isOpaque]); |
| 845 | 845 |
| 846 const IPC::Message* set_background; | 846 const IPC::Message* set_background; |
| 847 set_background = process_host->sink().GetUniqueMessageMatching( | 847 set_background = process_host->sink().GetUniqueMessageMatching( |
| 848 ViewMsg_SetBackgroundOpaque::ID); | 848 ViewMsg_SetBackgroundOpaque::ID); |
| 849 ASSERT_TRUE(set_background); | 849 ASSERT_TRUE(set_background); |
| 850 Tuple<bool> sent_background; | 850 base::Tuple<bool> sent_background; |
| 851 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); | 851 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); |
| 852 EXPECT_FALSE(get<0>(sent_background)); | 852 EXPECT_FALSE(base::get<0>(sent_background)); |
| 853 | 853 |
| 854 // Try setting it back. | 854 // Try setting it back. |
| 855 process_host->sink().ClearMessages(); | 855 process_host->sink().ClearMessages(); |
| 856 view->SetBackgroundColor(SK_ColorWHITE); | 856 view->SetBackgroundColor(SK_ColorWHITE); |
| 857 EXPECT_TRUE(view->GetBackgroundOpaque()); | 857 EXPECT_TRUE(view->GetBackgroundOpaque()); |
| 858 EXPECT_TRUE([view->cocoa_view() isOpaque]); | 858 EXPECT_TRUE([view->cocoa_view() isOpaque]); |
| 859 set_background = process_host->sink().GetUniqueMessageMatching( | 859 set_background = process_host->sink().GetUniqueMessageMatching( |
| 860 ViewMsg_SetBackgroundOpaque::ID); | 860 ViewMsg_SetBackgroundOpaque::ID); |
| 861 ASSERT_TRUE(set_background); | 861 ASSERT_TRUE(set_background); |
| 862 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); | 862 ViewMsg_SetBackgroundOpaque::Read(set_background, &sent_background); |
| 863 EXPECT_TRUE(get<0>(sent_background)); | 863 EXPECT_TRUE(base::get<0>(sent_background)); |
| 864 | 864 |
| 865 host->Shutdown(); | 865 host->Shutdown(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 class RenderWidgetHostViewMacPinchTest : public RenderWidgetHostViewMacTest { | 868 class RenderWidgetHostViewMacPinchTest : public RenderWidgetHostViewMacTest { |
| 869 public: | 869 public: |
| 870 RenderWidgetHostViewMacPinchTest() : process_host_(NULL) {} | 870 RenderWidgetHostViewMacPinchTest() : process_host_(NULL) {} |
| 871 | 871 |
| 872 bool ZoomDisabledForPinchUpdateMessage() { | 872 bool ZoomDisabledForPinchUpdateMessage() { |
| 873 const IPC::Message* message = NULL; | 873 const IPC::Message* message = NULL; |
| 874 // The first message may be a PinchBegin. Go for the second message if | 874 // The first message may be a PinchBegin. Go for the second message if |
| 875 // there are two. | 875 // there are two. |
| 876 switch (process_host_->sink().message_count()) { | 876 switch (process_host_->sink().message_count()) { |
| 877 case 1: | 877 case 1: |
| 878 message = process_host_->sink().GetMessageAt(0); | 878 message = process_host_->sink().GetMessageAt(0); |
| 879 break; | 879 break; |
| 880 case 2: | 880 case 2: |
| 881 message = process_host_->sink().GetMessageAt(1); | 881 message = process_host_->sink().GetMessageAt(1); |
| 882 break; | 882 break; |
| 883 default: | 883 default: |
| 884 NOTREACHED(); | 884 NOTREACHED(); |
| 885 break; | 885 break; |
| 886 } | 886 } |
| 887 DCHECK(message); | 887 DCHECK(message); |
| 888 Tuple<IPC::WebInputEventPointer, ui::LatencyInfo, bool> data; | 888 base::Tuple<IPC::WebInputEventPointer, ui::LatencyInfo, bool> data; |
| 889 InputMsg_HandleInputEvent::Read(message, &data); | 889 InputMsg_HandleInputEvent::Read(message, &data); |
| 890 IPC::WebInputEventPointer ipc_event = get<0>(data); | 890 IPC::WebInputEventPointer ipc_event = base::get<0>(data); |
| 891 const blink::WebGestureEvent* gesture_event = | 891 const blink::WebGestureEvent* gesture_event = |
| 892 static_cast<const blink::WebGestureEvent*>(ipc_event); | 892 static_cast<const blink::WebGestureEvent*>(ipc_event); |
| 893 return gesture_event->data.pinchUpdate.zoomDisabled; | 893 return gesture_event->data.pinchUpdate.zoomDisabled; |
| 894 } | 894 } |
| 895 | 895 |
| 896 MockRenderProcessHost* process_host_; | 896 MockRenderProcessHost* process_host_; |
| 897 }; | 897 }; |
| 898 | 898 |
| 899 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { | 899 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { |
| 900 // This tests Lion+ functionality, so don't run the test pre-Lion. | 900 // This tests Lion+ functionality, so don't run the test pre-Lion. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1010 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1011 process_host_->sink().ClearMessages(); | 1011 process_host_->sink().ClearMessages(); |
| 1012 } | 1012 } |
| 1013 | 1013 |
| 1014 // Clean up. | 1014 // Clean up. |
| 1015 host->Shutdown(); | 1015 host->Shutdown(); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 | 1018 |
| 1019 } // namespace content | 1019 } // namespace content |
| OLD | NEW |