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 "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/automation/automation_window_tracker.h" | 8 #include "chrome/browser/automation/automation_window_tracker.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/base/ui_base_types.h" | 11 #include "ui/base/ui_base_types.h" |
12 | 12 |
13 #if defined(USE_ASH) | 13 #if defined(USE_ASH) |
14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
15 #endif | 15 #endif |
16 | 16 |
17 void TestingAutomationProvider::ActivateWindow(int handle) { | |
18 #if defined(USE_ASH) | |
19 aura::Window* window = window_tracker_->GetResource(handle); | |
20 if (window) { | |
21 ash::wm::ActivateWindow(window); | |
22 } | |
23 #else | |
24 NOTIMPLEMENTED(); | |
25 #endif | |
26 } | |
27 | |
28 void TestingAutomationProvider::IsWindowMaximized(int handle, | |
29 bool* is_maximized, | |
30 bool* success) { | |
31 aura::Window* window = window_tracker_->GetResource(handle); | |
32 if (window) { | |
33 *is_maximized = window->GetProperty(aura::client::kShowStateKey) == | |
34 ui::SHOW_STATE_MAXIMIZED; | |
35 *success = true; | |
36 } else { | |
37 *success = false; | |
38 } | |
39 } | |
40 | |
41 void TestingAutomationProvider::TerminateSession(int handle, bool* success) { | 17 void TestingAutomationProvider::TerminateSession(int handle, bool* success) { |
42 *success = false; | 18 *success = false; |
43 } | 19 } |
44 | 20 |
45 void TestingAutomationProvider::GetWindowBounds(int handle, | |
46 gfx::Rect* bounds, | |
47 bool* success) { | |
48 const aura::Window* window = window_tracker_->GetResource(handle); | |
49 if (window) { | |
50 *bounds = window->bounds(); | |
51 *success = true; | |
52 } else { | |
53 *success = false; | |
54 } | |
55 } | |
56 | |
57 void TestingAutomationProvider::SetWindowBounds(int handle, | 21 void TestingAutomationProvider::SetWindowBounds(int handle, |
58 const gfx::Rect& bounds, | 22 const gfx::Rect& bounds, |
59 bool* success) { | 23 bool* success) { |
60 aura::Window* window = window_tracker_->GetResource(handle); | 24 aura::Window* window = window_tracker_->GetResource(handle); |
61 if (window) { | 25 if (window) { |
62 window->SetBounds(bounds); | 26 window->SetBounds(bounds); |
63 *success = true; | 27 *success = true; |
64 } else { | 28 } else { |
65 *success = false; | 29 *success = false; |
66 } | 30 } |
67 } | 31 } |
68 | |
69 void TestingAutomationProvider::SetWindowVisible(int handle, | |
70 bool visible, | |
71 bool* result) { | |
72 aura::Window* window = window_tracker_->GetResource(handle); | |
73 if (window) { | |
74 if (visible) { | |
75 window->Show(); | |
76 } else { | |
77 window->Hide(); | |
78 } | |
79 *result = true; | |
80 } else { | |
81 *result = false; | |
82 } | |
83 } | |
84 | |
85 void TestingAutomationProvider::GetWindowTitle(int handle, string16* text) { | |
86 const aura::Window* window = window_tracker_->GetResource(handle); | |
87 DCHECK(window); | |
88 *text = window->title(); | |
89 } | |
OLD | NEW |