| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/android/tab_model/tab_model.h" | 5 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 6 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 6 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 7 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // A fake value for the current number of tabs. | 36 // A fake value for the current number of tabs. |
| 37 int tab_count_; | 37 int tab_count_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Regression test for http://crbug.com/432685. | 40 // Regression test for http://crbug.com/432685. |
| 41 TEST_F(TabModelListTest, TestGetTabModelForWebContents) { | 41 TEST_F(TabModelListTest, TestGetTabModelForWebContents) { |
| 42 TestTabModel tab_model(profile()); | 42 TestTabModel tab_model(profile()); |
| 43 TabModelList::AddTabModel(&tab_model); | 43 TabModelList::AddTabModel(&tab_model); |
| 44 | 44 |
| 45 scoped_ptr<content::WebContents> contents(CreateTestWebContents()); | 45 std::unique_ptr<content::WebContents> contents(CreateTestWebContents()); |
| 46 | 46 |
| 47 // Should not crash when there are no tabs. | 47 // Should not crash when there are no tabs. |
| 48 EXPECT_EQ(NULL, TabModelList::GetTabModelForWebContents(contents.get())); | 48 EXPECT_EQ(NULL, TabModelList::GetTabModelForWebContents(contents.get())); |
| 49 | 49 |
| 50 // Should not crash when there is an uninitialized tab, i.e. when | 50 // Should not crash when there is an uninitialized tab, i.e. when |
| 51 // TabModel::GetTabAt returns NULL. | 51 // TabModel::GetTabAt returns NULL. |
| 52 tab_model.tab_count_ = 1; | 52 tab_model.tab_count_ = 1; |
| 53 EXPECT_EQ(NULL, TabModelList::GetTabModelForWebContents(contents.get())); | 53 EXPECT_EQ(NULL, TabModelList::GetTabModelForWebContents(contents.get())); |
| 54 | 54 |
| 55 TabModelList::RemoveTabModel(&tab_model); | 55 TabModelList::RemoveTabModel(&tab_model); |
| 56 } | 56 } |
| OLD | NEW |