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

Side by Side Diff: chrome/test/automation/automation_proxy_uitest.cc

Issue 100173: Remove ifdefs now that Mac passes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 TEST_F(AutomationProxyTest, GetTabCount) { 162 TEST_F(AutomationProxyTest, GetTabCount) {
163 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 163 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
164 ASSERT_TRUE(window.get()); 164 ASSERT_TRUE(window.get());
165 165
166 int tab_count = 0; 166 int tab_count = 0;
167 ASSERT_TRUE(window->GetTabCount(&tab_count)); 167 ASSERT_TRUE(window->GetTabCount(&tab_count));
168 ASSERT_EQ(1, tab_count); 168 ASSERT_EQ(1, tab_count);
169 } 169 }
170 170
171 // TODO(port): Port to mac. 171 // TODO(port): Port to mac.
Avi (use Gerrit) 2009/04/29 20:55:49 Obsolete comment?
pink (ping after 24hrs) 2009/04/29 20:59:13 Done.
172 #if defined(OS_WIN) || defined(OS_LINUX)
173 TEST_F(AutomationProxyTest, GetActiveTabIndex) { 172 TEST_F(AutomationProxyTest, GetActiveTabIndex) {
174 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 173 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
175 ASSERT_TRUE(window.get()); 174 ASSERT_TRUE(window.get());
176 175
177 int active_tab_index = -1; 176 int active_tab_index = -1;
178 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); 177 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index));
179 ASSERT_EQ(0, active_tab_index); 178 ASSERT_EQ(0, active_tab_index);
180 } 179 }
181 #endif
182 180
183 TEST_F(AutomationProxyVisibleTest, AppendTab) { 181 TEST_F(AutomationProxyVisibleTest, AppendTab) {
184 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 182 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
185 ASSERT_TRUE(window.get()); 183 ASSERT_TRUE(window.get());
186 184
187 int original_tab_count; 185 int original_tab_count;
188 ASSERT_TRUE(window->GetTabCount(&original_tab_count)); 186 ASSERT_TRUE(window->GetTabCount(&original_tab_count));
189 ASSERT_EQ(1, original_tab_count); // By default there are 2 tabs opened. 187 ASSERT_EQ(1, original_tab_count); // By default there are 2 tabs opened.
190 188
191 int original_active_tab_index; 189 int original_active_tab_index;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 file_util::AppendToPath(&document2_, L"title2.html"); 392 file_util::AppendToPath(&document2_, L"title2.html");
395 launch_arguments_ = CommandLine(L""); 393 launch_arguments_ = CommandLine(L"");
396 launch_arguments_.AppendLooseValue(document1_); 394 launch_arguments_.AppendLooseValue(document1_);
397 launch_arguments_.AppendLooseValue(document2_); 395 launch_arguments_.AppendLooseValue(document2_);
398 } 396 }
399 397
400 std::wstring document1_; 398 std::wstring document1_;
401 std::wstring document2_; 399 std::wstring document2_;
402 }; 400 };
403 401
404 // TODO(port): Port to mac.
405 #if defined(OS_WIN) || defined(OS_LINUX)
406 TEST_F(AutomationProxyTest2, GetActiveTabIndex) { 402 TEST_F(AutomationProxyTest2, GetActiveTabIndex) {
407 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 403 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
408 ASSERT_TRUE(window.get()); 404 ASSERT_TRUE(window.get());
409 405
410 int active_tab_index = -1; 406 int active_tab_index = -1;
411 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); 407 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index));
412 int tab_count; 408 int tab_count;
413 ASSERT_TRUE(window->GetTabCount(&tab_count)); 409 ASSERT_TRUE(window->GetTabCount(&tab_count));
414 ASSERT_EQ(0, active_tab_index); 410 ASSERT_EQ(0, active_tab_index);
415 int at_index = 1; 411 int at_index = 1;
416 ASSERT_TRUE(window->ActivateTab(at_index)); 412 ASSERT_TRUE(window->ActivateTab(at_index));
417 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); 413 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index));
418 ASSERT_EQ(at_index, active_tab_index); 414 ASSERT_EQ(at_index, active_tab_index);
419 } 415 }
420 416
421 TEST_F(AutomationProxyTest2, GetTabTitle) { 417 TEST_F(AutomationProxyTest2, GetTabTitle) {
422 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 418 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
423 ASSERT_TRUE(window.get()); 419 ASSERT_TRUE(window.get());
424 scoped_ptr<TabProxy> tab(window->GetTab(0)); 420 scoped_ptr<TabProxy> tab(window->GetTab(0));
425 ASSERT_TRUE(tab.get()); 421 ASSERT_TRUE(tab.get());
426 std::wstring title; 422 std::wstring title;
427 ASSERT_TRUE(tab->GetTabTitle(&title)); 423 ASSERT_TRUE(tab->GetTabTitle(&title));
428 ASSERT_STREQ(L"title1.html", title.c_str()); 424 ASSERT_STREQ(L"title1.html", title.c_str());
429 425
430 tab.reset(window->GetTab(1)); 426 tab.reset(window->GetTab(1));
431 ASSERT_TRUE(tab.get()); 427 ASSERT_TRUE(tab.get());
432 ASSERT_TRUE(tab->GetTabTitle(&title)); 428 ASSERT_TRUE(tab->GetTabTitle(&title));
433 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); 429 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str());
434 } 430 }
435 #endif
436 431
437 TEST_F(AutomationProxyTest, Cookies) { 432 TEST_F(AutomationProxyTest, Cookies) {
438 GURL url("http://mojo.jojo.google.com"); 433 GURL url("http://mojo.jojo.google.com");
439 std::string value_result; 434 std::string value_result;
440 435
441 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 436 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
442 ASSERT_TRUE(window.get()); 437 ASSERT_TRUE(window.get());
443 438
444 scoped_ptr<TabProxy> tab(window->GetTab(0)); 439 scoped_ptr<TabProxy> tab(window->GetTab(0));
445 ASSERT_TRUE(tab.get()); 440 ASSERT_TRUE(tab.get());
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 std::wstring document1_; 603 std::wstring document1_;
609 }; 604 };
610 605
611 std::wstring CreateJSStringForDOMQuery(const std::wstring& id) { 606 std::wstring CreateJSStringForDOMQuery(const std::wstring& id) {
612 std::wstring jscript(L"window.domAutomationController"); 607 std::wstring jscript(L"window.domAutomationController");
613 StringAppendF(&jscript, L".send(document.getElementById('%ls').nodeName);", 608 StringAppendF(&jscript, L".send(document.getElementById('%ls').nodeName);",
614 id.c_str()); 609 id.c_str());
615 return jscript; 610 return jscript;
616 } 611 }
617 612
618 // TODO(port): Port to mac.
619 #if defined(OS_WIN) || defined(OS_LINUX)
620 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) { 613 TEST_F(AutomationProxyTest3, FrameDocumentCanBeAccessed) {
621 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 614 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
622 ASSERT_TRUE(window.get()); 615 ASSERT_TRUE(window.get());
623 616
624 scoped_ptr<TabProxy> tab(window->GetTab(0)); 617 scoped_ptr<TabProxy> tab(window->GetTab(0));
625 ASSERT_TRUE(tab.get()); 618 ASSERT_TRUE(tab.get());
626 619
627 std::wstring actual; 620 std::wstring actual;
628 std::wstring xpath1 = L""; // top level frame 621 std::wstring xpath1 = L""; // top level frame
629 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput"); 622 std::wstring jscript1 = CreateJSStringForDOMQuery(L"myinput");
(...skipping 27 matching lines...) Expand all
657 PlatformThread::Sleep(sleep_timeout_ms()); 650 PlatformThread::Sleep(sleep_timeout_ms());
658 ASSERT_TRUE(tab->GetTabTitle(&title)); 651 ASSERT_TRUE(tab->GetTabTitle(&title));
659 if (title == L"Destinations") 652 if (title == L"Destinations")
660 break; 653 break;
661 } 654 }
662 // If we got to 10, the new tab failed to open. 655 // If we got to 10, the new tab failed to open.
663 ASSERT_NE(10, i); 656 ASSERT_NE(10, i);
664 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); 657 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual));
665 #endif 658 #endif
666 } 659 }
667 #endif // defined(OS_WIN) || defined(OS_LINUX)
668 660
669 // TODO(port): Need to port constrained_window_proxy.* first. 661 // TODO(port): Need to port constrained_window_proxy.* first.
670 #if defined(OS_WIN) 662 #if defined(OS_WIN)
671 TEST_F(AutomationProxyTest, DISABLED_ConstrainedWindowTest) { 663 TEST_F(AutomationProxyTest, DISABLED_ConstrainedWindowTest) {
672 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 664 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
673 ASSERT_TRUE(window.get()); 665 ASSERT_TRUE(window.get());
674 666
675 scoped_ptr<TabProxy> tab(window->GetTab(0)); 667 scoped_ptr<TabProxy> tab(window->GetTab(0));
676 tab.reset(window->GetTab(0)); 668 tab.reset(window->GetTab(0));
677 ASSERT_TRUE(tab.get()); 669 ASSERT_TRUE(tab.get());
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1151
1160 // Allow some time for the popup to show up and close. 1152 // Allow some time for the popup to show up and close.
1161 PlatformThread::Sleep(2000); 1153 PlatformThread::Sleep(2000);
1162 1154
1163 std::wstring expected(L"string"); 1155 std::wstring expected(L"string");
1164 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); 1156 std::wstring jscript = CreateJSString(L"\"" + expected + L"\"");
1165 std::wstring actual; 1157 std::wstring actual;
1166 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); 1158 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual));
1167 ASSERT_STREQ(expected.c_str(), actual.c_str()); 1159 ASSERT_STREQ(expected.c_str(), actual.c_str());
1168 } 1160 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698