| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/views/controls/prefix_selector.h" | 5 #include "ui/views/controls/prefix_selector.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 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 28 matching lines...) Expand all Loading... |
| 39 int selected_row_; | 39 int selected_row_; |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(TestPrefixDelegate); | 41 DISALLOW_COPY_AND_ASSIGN(TestPrefixDelegate); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 class PrefixSelectorTest : public ViewsTestBase { | 44 class PrefixSelectorTest : public ViewsTestBase { |
| 45 public: | 45 public: |
| 46 PrefixSelectorTest() { | 46 PrefixSelectorTest() { |
| 47 selector_.reset(new PrefixSelector(&delegate_)); | 47 selector_.reset(new PrefixSelector(&delegate_)); |
| 48 } | 48 } |
| 49 ~PrefixSelectorTest() override { |
| 50 // Explicitly release |selector_| here which can happen before releasing |
| 51 // |delegate_|. |
| 52 selector_.reset(); |
| 53 } |
| 49 | 54 |
| 50 protected: | 55 protected: |
| 51 scoped_ptr<PrefixSelector> selector_; | 56 scoped_ptr<PrefixSelector> selector_; |
| 52 TestPrefixDelegate delegate_; | 57 TestPrefixDelegate delegate_; |
| 53 | 58 |
| 54 private: | 59 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(PrefixSelectorTest); | 60 DISALLOW_COPY_AND_ASSIGN(PrefixSelectorTest); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 TEST_F(PrefixSelectorTest, PrefixSelect) { | 63 TEST_F(PrefixSelectorTest, PrefixSelect) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 EXPECT_EQ(2, delegate_.GetSelectedRow()); | 79 EXPECT_EQ(2, delegate_.GetSelectedRow()); |
| 75 | 80 |
| 76 selector_->OnViewBlur(); | 81 selector_->OnViewBlur(); |
| 77 selector_->InsertText(ASCIIToUTF16("\t")); | 82 selector_->InsertText(ASCIIToUTF16("\t")); |
| 78 selector_->InsertText(ASCIIToUTF16("b")); | 83 selector_->InsertText(ASCIIToUTF16("b")); |
| 79 selector_->InsertText(ASCIIToUTF16("a")); | 84 selector_->InsertText(ASCIIToUTF16("a")); |
| 80 EXPECT_EQ(2, delegate_.GetSelectedRow()); | 85 EXPECT_EQ(2, delegate_.GetSelectedRow()); |
| 81 } | 86 } |
| 82 | 87 |
| 83 } // namespace views | 88 } // namespace views |
| OLD | NEW |