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

Side by Side Diff: content/browser/dom_storage/dom_storage_browsertest.cc

Issue 2700003002: Fix flaky MojoDOMStorageBrowserTest (Closed)
Patch Set: slightly nicer Created 3 years, 10 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
« 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
8 #include "content/browser/dom_storage/local_storage_context_mojo.h" 8 #include "content/browser/dom_storage/local_storage_context_mojo.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/dom_storage/dom_storage_types.h" 10 #include "content/common/dom_storage/dom_storage_types.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 }; 43 };
44 44
45 class MojoDOMStorageBrowserTest : public DOMStorageBrowserTest { 45 class MojoDOMStorageBrowserTest : public DOMStorageBrowserTest {
46 public: 46 public:
47 void SetUpCommandLine(base::CommandLine* command_line) override { 47 void SetUpCommandLine(base::CommandLine* command_line) override {
48 ContentBrowserTest::SetUpCommandLine(command_line); 48 ContentBrowserTest::SetUpCommandLine(command_line);
49 command_line->AppendSwitch(switches::kMojoLocalStorage); 49 command_line->AppendSwitch(switches::kMojoLocalStorage);
50 } 50 }
51 51
52 LocalStorageContextMojo* context() {
53 return static_cast<DOMStorageContextWrapper*>(
54 BrowserContext::GetDefaultStoragePartition(
55 shell()->web_contents()->GetBrowserContext())
56 ->GetDOMStorageContext())
57 ->mojo_state_.get();
58 }
59
60 void EnsureConnected() {
61 base::RunLoop run_loop;
62 context()->RunWhenConnected(run_loop.QuitClosure());
63 run_loop.Run();
64 }
65
52 void Flush() { 66 void Flush() {
53 // First make sure a connection to the database was set up. 67 // Process any tasks that are currently queued, to ensure
54 LocalStorageContextMojo* context =
55 static_cast<DOMStorageContextWrapper*>(
56 BrowserContext::GetDefaultStoragePartition(
57 shell()->web_contents()->GetBrowserContext())
58 ->GetDOMStorageContext())
59 ->mojo_state_.get();
60 base::RunLoop run_loop;
61 context->RunWhenConnected(run_loop.QuitClosure());
62 run_loop.Run();
63 // Then process any tasks that are currently queued, to ensure
64 // LevelDBWrapperImpl methods get called. 68 // LevelDBWrapperImpl methods get called.
65 base::RunLoop().RunUntilIdle(); 69 base::RunLoop().RunUntilIdle();
66 // And finally flush all the now queued up changes to leveldb. 70 // And finally flush all the now queued up changes to leveldb.
67 context->Flush(); 71 context()->Flush();
72 base::RunLoop().RunUntilIdle();
68 } 73 }
69 }; 74 };
70 75
71 static const bool kIncognito = true; 76 static const bool kIncognito = true;
72 static const bool kNotIncognito = false; 77 static const bool kNotIncognito = false;
73 78
74 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) { 79 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheck) {
75 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito); 80 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
76 } 81 }
77 82
78 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheckIncognito) { 83 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, SanityCheckIncognito) {
79 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito); 84 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito);
80 } 85 }
81 86
82 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, PRE_DataPersists) { 87 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, PRE_DataPersists) {
83 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito); 88 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito);
84 } 89 }
85 90
86 // http://crbug.com/654704 PRE_ tests aren't supported on Android. 91 // http://crbug.com/654704 PRE_ tests aren't supported on Android.
87 #if defined(OS_ANDROID) 92 #if defined(OS_ANDROID)
88 #define MAYBE_DataPersists DISABLED_DataPersists 93 #define MAYBE_DataPersists DISABLED_DataPersists
89 #elif defined(OS_WIN) || defined(OS_LINUX)
90 // Disabled on Windows and Linux due to flake (https://crbug.com/692885).
91 #define MAYBE_DataPersists DISABLED_DataPersists
92 #else 94 #else
93 #define MAYBE_DataPersists DataPersists 95 #define MAYBE_DataPersists DataPersists
94 #endif 96 #endif
95 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, MAYBE_DataPersists) { 97 IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, MAYBE_DataPersists) {
96 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); 98 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito);
97 } 99 }
98 100
99 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheck) { 101 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheck) {
100 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito); 102 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kNotIncognito);
101 } 103 }
102 104
103 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheckIncognito) { 105 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, SanityCheckIncognito) {
104 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito); 106 SimpleTest(GetTestUrl("dom_storage", "sanity_check.html"), kIncognito);
105 } 107 }
106 108
107 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, PRE_DataPersists) { 109 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, PRE_DataPersists) {
110 EnsureConnected();
108 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito); 111 SimpleTest(GetTestUrl("dom_storage", "store_data.html"), kNotIncognito);
109 Flush(); 112 Flush();
110 } 113 }
111 114
112 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, MAYBE_DataPersists) { 115 IN_PROC_BROWSER_TEST_F(MojoDOMStorageBrowserTest, MAYBE_DataPersists) {
113 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito); 116 SimpleTest(GetTestUrl("dom_storage", "verify_data.html"), kNotIncognito);
114 } 117 }
115 118
116 } // namespace content 119 } // namespace content
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