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

Side by Side Diff: ui/views/view_unittest.cc

Issue 117983002: Prefix string16 with base:: in ui/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years 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 | « ui/views/view.cc ('k') | ui/views/views_delegate.h » ('j') | 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) 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 <map> 5 #include <map>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 gfx::Point p7(21, 0); 1427 gfx::Point p7(21, 0);
1428 ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0, 0); 1428 ui::MouseEvent mouse7(ui::ET_MOUSE_MOVED, p7, p7, 0, 0);
1429 root_view->OnMouseMoved(mouse7); 1429 root_view->OnMouseMoved(mouse7);
1430 EXPECT_TRUE(v11->received_mouse_exit_); 1430 EXPECT_TRUE(v11->received_mouse_exit_);
1431 EXPECT_FALSE(v1->received_mouse_enter_); 1431 EXPECT_FALSE(v1->received_mouse_enter_);
1432 1432
1433 widget->CloseNow(); 1433 widget->CloseNow();
1434 } 1434 }
1435 1435
1436 TEST_F(ViewTest, Textfield) { 1436 TEST_F(ViewTest, Textfield) {
1437 const string16 kText = ASCIIToUTF16("Reality is that which, when you stop " 1437 const base::string16 kText = ASCIIToUTF16(
1438 "believing it, doesn't go away."); 1438 "Reality is that which, when you stop believing it, doesn't go away.");
1439 const string16 kExtraText = ASCIIToUTF16("Pretty deep, Philip!"); 1439 const base::string16 kExtraText = ASCIIToUTF16("Pretty deep, Philip!");
1440 const string16 kEmptyString; 1440 const base::string16 kEmptyString;
1441 1441
1442 Widget* widget = new Widget; 1442 Widget* widget = new Widget;
1443 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 1443 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
1444 params.bounds = gfx::Rect(0, 0, 100, 100); 1444 params.bounds = gfx::Rect(0, 0, 100, 100);
1445 widget->Init(params); 1445 widget->Init(params);
1446 View* root_view = widget->GetRootView(); 1446 View* root_view = widget->GetRootView();
1447 1447
1448 Textfield* textfield = new Textfield(); 1448 Textfield* textfield = new Textfield();
1449 root_view->AddChildView(textfield); 1449 root_view->AddChildView(textfield);
1450 1450
1451 // Test setting, appending text. 1451 // Test setting, appending text.
1452 textfield->SetText(kText); 1452 textfield->SetText(kText);
1453 EXPECT_EQ(kText, textfield->text()); 1453 EXPECT_EQ(kText, textfield->text());
1454 textfield->AppendText(kExtraText); 1454 textfield->AppendText(kExtraText);
1455 EXPECT_EQ(kText + kExtraText, textfield->text()); 1455 EXPECT_EQ(kText + kExtraText, textfield->text());
1456 textfield->SetText(string16()); 1456 textfield->SetText(base::string16());
1457 EXPECT_EQ(kEmptyString, textfield->text()); 1457 EXPECT_EQ(kEmptyString, textfield->text());
1458 1458
1459 // Test selection related methods. 1459 // Test selection related methods.
1460 textfield->SetText(kText); 1460 textfield->SetText(kText);
1461 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); 1461 EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
1462 textfield->SelectAll(false); 1462 textfield->SelectAll(false);
1463 EXPECT_EQ(kText, textfield->text()); 1463 EXPECT_EQ(kText, textfield->text());
1464 textfield->ClearSelection(); 1464 textfield->ClearSelection();
1465 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); 1465 EXPECT_EQ(kEmptyString, textfield->GetSelectedText());
1466 1466
1467 widget->CloseNow(); 1467 widget->CloseNow();
1468 } 1468 }
1469 1469
1470 // Tests that the Textfield view respond appropiately to cut/copy/paste. 1470 // Tests that the Textfield view respond appropiately to cut/copy/paste.
1471 TEST_F(ViewTest, TextfieldCutCopyPaste) { 1471 TEST_F(ViewTest, TextfieldCutCopyPaste) {
1472 const string16 kNormalText = ASCIIToUTF16("Normal"); 1472 const base::string16 kNormalText = ASCIIToUTF16("Normal");
1473 const string16 kReadOnlyText = ASCIIToUTF16("Read only"); 1473 const base::string16 kReadOnlyText = ASCIIToUTF16("Read only");
1474 const string16 kPasswordText = ASCIIToUTF16("Password! ** Secret stuff **"); 1474 const base::string16 kPasswordText =
1475 ASCIIToUTF16("Password! ** Secret stuff **");
1475 1476
1476 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 1477 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1477 1478
1478 Widget* widget = new Widget; 1479 Widget* widget = new Widget;
1479 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 1480 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
1480 params.bounds = gfx::Rect(0, 0, 100, 100); 1481 params.bounds = gfx::Rect(0, 0, 100, 100);
1481 widget->Init(params); 1482 widget->Init(params);
1482 View* root_view = widget->GetRootView(); 1483 View* root_view = widget->GetRootView();
1483 1484
1484 Textfield* normal = new Textfield(); 1485 Textfield* normal = new Textfield();
1485 Textfield* read_only = new Textfield(); 1486 Textfield* read_only = new Textfield();
1486 read_only->SetReadOnly(true); 1487 read_only->SetReadOnly(true);
1487 Textfield* password = new Textfield(Textfield::STYLE_OBSCURED); 1488 Textfield* password = new Textfield(Textfield::STYLE_OBSCURED);
1488 1489
1489 root_view->AddChildView(normal); 1490 root_view->AddChildView(normal);
1490 root_view->AddChildView(read_only); 1491 root_view->AddChildView(read_only);
1491 root_view->AddChildView(password); 1492 root_view->AddChildView(password);
1492 1493
1493 normal->SetText(kNormalText); 1494 normal->SetText(kNormalText);
1494 read_only->SetText(kReadOnlyText); 1495 read_only->SetText(kReadOnlyText);
1495 password->SetText(kPasswordText); 1496 password->SetText(kPasswordText);
1496 1497
1497 // 1498 //
1498 // Test cut. 1499 // Test cut.
1499 // 1500 //
1500 1501
1501 normal->SelectAll(false); 1502 normal->SelectAll(false);
1502 normal->ExecuteCommand(IDS_APP_CUT); 1503 normal->ExecuteCommand(IDS_APP_CUT);
1503 string16 result; 1504 base::string16 result;
1504 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 1505 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
1505 EXPECT_EQ(kNormalText, result); 1506 EXPECT_EQ(kNormalText, result);
1506 normal->SetText(kNormalText); // Let's revert to the original content. 1507 normal->SetText(kNormalText); // Let's revert to the original content.
1507 1508
1508 read_only->SelectAll(false); 1509 read_only->SelectAll(false);
1509 read_only->ExecuteCommand(IDS_APP_CUT); 1510 read_only->ExecuteCommand(IDS_APP_CUT);
1510 result.clear(); 1511 result.clear();
1511 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 1512 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
1512 // Cut should have failed, so the clipboard content should not have changed. 1513 // Cut should have failed, so the clipboard content should not have changed.
1513 EXPECT_EQ(kNormalText, result); 1514 EXPECT_EQ(kNormalText, result);
(...skipping 1993 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 const std::vector<ui::Layer*>& child_layers_post = root_layer->children(); 3508 const std::vector<ui::Layer*>& child_layers_post = root_layer->children();
3508 ASSERT_EQ(3u, child_layers_post.size()); 3509 ASSERT_EQ(3u, child_layers_post.size());
3509 EXPECT_EQ(v1->layer(), child_layers_post[0]); 3510 EXPECT_EQ(v1->layer(), child_layers_post[0]);
3510 EXPECT_EQ(v2->layer(), child_layers_post[1]); 3511 EXPECT_EQ(v2->layer(), child_layers_post[1]);
3511 EXPECT_EQ(v1_old_layer, child_layers_post[2]); 3512 EXPECT_EQ(v1_old_layer, child_layers_post[2]);
3512 } 3513 }
3513 3514
3514 #endif // USE_AURA 3515 #endif // USE_AURA
3515 3516
3516 } // namespace views 3517 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698